THRIFT-5398 ThreadPoolServer not stoppable via CancellationToken
Client: netstd
Patch: Jens Geyer

This closes #2376
diff --git a/lib/netstd/Thrift/Server/TThreadPoolAsyncServer.cs b/lib/netstd/Thrift/Server/TThreadPoolAsyncServer.cs
index 20e659d..877d595 100644
--- a/lib/netstd/Thrift/Server/TThreadPoolAsyncServer.cs
+++ b/lib/netstd/Thrift/Server/TThreadPoolAsyncServer.cs
@@ -172,19 +172,21 @@
                 if (ServerEventHandler != null)
                     await ServerEventHandler.PreServeAsync(cancellationToken);
 
-                while (!stop)
+                while (!(stop || ServerCancellationToken.IsCancellationRequested))
                 {
-                    int failureCount = 0;
                     try
                     {
                         TTransport client = await ServerTransport.AcceptAsync(cancellationToken);
                         ThreadPool.QueueUserWorkItem(this.Execute, client);
                     }
+                    catch (TaskCanceledException)
+                    {
+                        stop = true;
+                    }
                     catch (TTransportException ttx)
                     {
                         if (!stop || ttx.Type != TTransportException.ExceptionType.Interrupted)
                         {
-                            ++failureCount;
                             LogError(ttx.ToString());
                         }