THRIFT-5210 further refactoring and performance optimizations
Client: netstd
Patch: Jens Geyer

This closes #2146
diff --git a/lib/netstd/Thrift/TApplicationException.cs b/lib/netstd/Thrift/TApplicationException.cs
index 67ac2f8..514db9a 100644
--- a/lib/netstd/Thrift/TApplicationException.cs
+++ b/lib/netstd/Thrift/TApplicationException.cs
@@ -1,4 +1,4 @@
-// Licensed to the Apache Software Foundation(ASF) under one
+// Licensed to the Apache Software Foundation(ASF) under one
 // or more contributor license agreements.See the NOTICE file
 // distributed with this work for additional information
 // regarding copyright ownership.The ASF licenses this file
@@ -112,10 +112,7 @@
 
         public async Task WriteAsync(TProtocol outputProtocol, CancellationToken cancellationToken)
         {
-            if (cancellationToken.IsCancellationRequested)
-            {
-                await Task.FromCanceled(cancellationToken);
-            }
+            cancellationToken.ThrowIfCancellationRequested();
 
             const string messageTypeFieldName = "message";
             const string exTypeFieldName = "exType";
@@ -147,4 +144,4 @@
             await outputProtocol.WriteStructEndAsync(cancellationToken);
         }
     }
-}
\ No newline at end of file
+}