THRIFT-4673 IAsyncResult not supported by layered transports (buffered/framed)
Client: C#
Patch: Jens Geyer

This closes #1634
diff --git a/lib/csharp/src/Transport/TBufferedTransport.cs b/lib/csharp/src/Transport/TBufferedTransport.cs
index 76c6b1a..8870988 100644
--- a/lib/csharp/src/Transport/TBufferedTransport.cs
+++ b/lib/csharp/src/Transport/TBufferedTransport.cs
@@ -81,7 +81,7 @@
                 inputBuffer.Capacity = bufSize;
 
             while (true)
-            { 
+            {
                 int got = inputBuffer.Read(buf, off, len);
                 if (got > 0)
                     return got;
@@ -129,9 +129,8 @@
             }
         }
 
-        public override void Flush()
+        private void InternalFlush()
         {
-            CheckNotDisposed();
             if (!IsOpen)
                 throw new TTransportException(TTransportException.ExceptionType.NotOpen);
             if (outputBuffer.Length > 0)
@@ -139,9 +138,31 @@
                 transport.Write(outputBuffer.GetBuffer(), 0, (int)outputBuffer.Length);
                 outputBuffer.SetLength(0);
             }
+        }
+
+        public override void Flush()
+        {
+            CheckNotDisposed();
+            InternalFlush();
+
             transport.Flush();
         }
 
+        public override IAsyncResult BeginFlush(AsyncCallback callback, object state)
+        {
+            CheckNotDisposed();
+            InternalFlush();
+
+            return transport.BeginFlush( callback, state);
+        }
+
+        public override void EndFlush(IAsyncResult asyncResult)
+        {
+            transport.EndFlush( asyncResult);
+        }
+
+
+
         protected void CheckNotDisposed()
         {
             if (_IsDisposed)
diff --git a/lib/csharp/src/Transport/TFramedTransport.cs b/lib/csharp/src/Transport/TFramedTransport.cs
index 3436cc6..a746a32 100644
--- a/lib/csharp/src/Transport/TFramedTransport.cs
+++ b/lib/csharp/src/Transport/TFramedTransport.cs
@@ -108,7 +108,7 @@
             writeBuffer.Write(buf, off, len);
         }
 
-        public override void Flush()
+        private void InternalFlush()
         {
             CheckNotDisposed();
             if (!IsOpen)
@@ -126,10 +126,29 @@
             transport.Write(buf, 0, len);
 
             InitWriteBuffer();
+        }
+
+        public override void Flush()
+        {
+            CheckNotDisposed();
+            InternalFlush();
 
             transport.Flush();
         }
 
+        public override IAsyncResult BeginFlush(AsyncCallback callback, object state)
+        {
+            CheckNotDisposed();
+            InternalFlush();
+
+            return transport.BeginFlush( callback, state);
+        }
+
+        public override void EndFlush(IAsyncResult asyncResult)
+        {
+            transport.EndFlush( asyncResult);
+        }
+
         private void InitWriteBuffer()
         {
             // Reserve space for message header to be put right before sending it out