diff options
Diffstat (limited to 'mcs/class/corlib/System.Threading/ThreadPool.cs')
-rw-r--r-- | mcs/class/corlib/System.Threading/ThreadPool.cs | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/mcs/class/corlib/System.Threading/ThreadPool.cs b/mcs/class/corlib/System.Threading/ThreadPool.cs index 4d3f1c086c..204386f9f7 100644 --- a/mcs/class/corlib/System.Threading/ThreadPool.cs +++ b/mcs/class/corlib/System.Threading/ThreadPool.cs @@ -87,9 +87,6 @@ namespace System.Threading { if (ar == null) return false; } else { - if (!callBack.HasSingleTarget) - throw new Exception ("The delegate must have only one target"); - AsyncResult ares = new AsyncResult (callBack, state, true); pool_queue (ares); } @@ -99,6 +96,12 @@ namespace System.Threading { [MethodImplAttribute(MethodImplOptions.InternalCall)] static extern void pool_queue (AsyncResult ares); + // TODO: It should be interface interface only to avoid extra allocation + internal static void QueueWorkItem (WaitCallback callBack, object state) + { + pool_queue (new AsyncResult (callBack, state, false)); + } + public static RegisteredWaitHandle RegisterWaitForSingleObject (WaitHandle waitObject, WaitOrTimerCallback callBack, object state, @@ -168,11 +171,11 @@ namespace System.Threading { [SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)] public static bool UnsafeQueueUserWorkItem (WaitCallback callBack, object state) { + if (callBack == null) + throw new ArgumentNullException ("callBack"); + // no stack propagation here (that's why it's unsafe and requires extra security permissions) if (!callBack.IsTransparentProxy ()) { - if (!callBack.HasSingleTarget) - throw new Exception ("The delegate must have only one target"); - AsyncResult ares = new AsyncResult (callBack, state, false); pool_queue (ares); return true; |