Merge pull request #409 from Alkarex/patch-1
[mono.git] / mcs / class / System / System.Net / WebAsyncResult.cs
index 7b31ba10d15977189c8a96bffd46ad6797ce9246..7cc9d5e1d8bfca35b1ff1e4cc3357efcde210204 100644 (file)
@@ -44,13 +44,14 @@ namespace System.Net
                IAsyncResult innerAsyncResult;
                bool callbackDone;
                Exception exc;
-               HttpWebRequest request;
                HttpWebResponse response;
                Stream writeStream;
                byte [] buffer;
                int offset;
                int size;
                object locker = new object ();
+               public bool EndCalled;
+               public bool AsyncWriteAll;
 
                public WebAsyncResult (AsyncCallback cb, object state)
                {
@@ -60,7 +61,6 @@ namespace System.Net
 
                public WebAsyncResult (HttpWebRequest request, AsyncCallback cb, object state)
                {
-                       this.request = request;
                        this.cb = cb;
                        this.state = state;
                }
@@ -89,7 +89,6 @@ namespace System.Net
                {
                        callbackDone = false;
                        exc = null;
-                       request = null;
                        response = null;
                        writeStream = null;
                        exc = null;
@@ -140,9 +139,17 @@ namespace System.Net
                {
                        if (!callbackDone && cb != null) {
                                callbackDone = true;
-                               cb (this);
+                               if (synch)
+                                       cb (this);
+                               else
+                                       ThreadPool.QueueUserWorkItem (CB, null);
                        }
                }
+
+               void CB (object unused)
+               {
+                       cb (this);
+               }
                
                internal void WaitUntilComplete ()
                {