[WebConnection] Use just one delegate to init the connection
authorAndres G. Aragoneses <knocte@gmail.com>
Fri, 8 Feb 2013 14:36:50 +0000 (14:36 +0000)
committerAndres G. Aragoneses <knocte@gmail.com>
Fri, 8 Feb 2013 14:36:50 +0000 (14:36 +0000)
As suggested by Marek Safar, using WaitCallback without the threadpool
is just fine, so revert back to using one delegate.

mcs/class/System/System.Net/WebConnection.cs

index ff443c7d4800f4f22bd0e84d5ff379d8d40533c2..78b27a372bbace6c1fa7a564ac788ae9b56338aa 100644 (file)
@@ -58,7 +58,6 @@ namespace System.Net
                object socketLock = new object ();
                WebExceptionStatus status;
                WaitCallback initConn;
-               Action<object> initConnDelegate;
                bool keepAlive;
                byte [] buffer;
                static AsyncCallback readDoneDelegate = new AsyncCallback (ReadDone);
@@ -110,12 +109,11 @@ namespace System.Net
                        this.sPoint = sPoint;
                        buffer = new byte [4096];
                        Data = new WebConnectionData ();
-                       initConnDelegate = state => {
+                       initConn = new WaitCallback (state => {
                                try {
                                        InitConnection (state);
                                } catch {}
-                       };
-                       initConn = new WaitCallback (state => initConnDelegate (state));
+                               });
                        queue = group.Queue;
                        abortHelper = new AbortHelper ();
                        abortHelper.Connection = this;
@@ -793,7 +791,7 @@ namespace System.Net
                                        if (request.asynchronous)
                                                ThreadPool.QueueUserWorkItem (initConn, request);
                                        else
-                                               initConnDelegate (request);
+                                               initConn.Invoke (request);
                                } else {
                                        lock (queue) {
 #if MONOTOUCH