Skip to content

Instantly share code, notes, and snippets.

@knocte
Created January 24, 2013 17:26
Show Gist options
  • Save knocte/4625414 to your computer and use it in GitHub Desktop.
Save knocte/4625414 to your computer and use it in GitHub Desktop.
diff --git a/mcs/class/System/System.Net/WebConnection.cs b/mcs/class/System/System.Net/WebConnection.cs
index 4922fb3..bd505f3 100644
--- a/mcs/class/System/System.Net/WebConnection.cs
+++ b/mcs/class/System/System.Net/WebConnection.cs
@@ -58,6 +58,7 @@ namespace System.Net
object socketLock = new object ();
WebExceptionStatus status;
WaitCallback initConn;
+ Action<HttpWebRequest> initConnDelegate;
bool keepAlive;
byte [] buffer;
static AsyncCallback readDoneDelegate = new AsyncCallback (ReadDone);
@@ -109,11 +110,12 @@ namespace System.Net
this.sPoint = sPoint;
buffer = new byte [4096];
Data = new WebConnectionData ();
- initConn = new WaitCallback (state => {
+ initConnDelegate = state => {
try {
InitConnection (state);
} catch {}
- });
+ };
+ initConn = new WaitCallback (state => initConnDelegate ((HttpWebRequest)state));
queue = group.Queue;
abortHelper = new AbortHelper ();
abortHelper.Connection = this;
@@ -787,7 +789,12 @@ namespace System.Net
if (!busy) {
busy = true;
status = WebExceptionStatus.Success;
- ThreadPool.QueueUserWorkItem (initConn, request);
+
+ string managed = Environment.GetEnvironmentVariable ("MONO_DISABLE_WEBCONNECTION_THREADPOOL");
+ if (managed == null)
+ ThreadPool.QueueUserWorkItem (initConn, request);
+ else
+ initConnDelegate(request);
} else {
lock (queue) {
#if MONOTOUCH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment