The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ThreadPool.UnsafeQueueUserWorkItem Method

Queues a user work item to the thread pool.

[Visual Basic]
Public Shared Function UnsafeQueueUserWorkItem( _
   ByVal callBack As WaitCallback, _
   ByVal state As Object _
) As Boolean
public static bool UnsafeQueueUserWorkItem(
 WaitCallback callBack,
 object state
public: static bool UnsafeQueueUserWorkItem(
 WaitCallback* callBack,
 Object* state
public static function UnsafeQueueUserWorkItem(
   callBack : WaitCallback,
 state : Object
) : Boolean;


A WaitCallback representing the delegate to invoke when a thread in the thread pool picks up the work item.
The object that is passed to the delegate when serviced from the thread pool.

Return Value

true if the method succeeds; otherwise, false.


Exception Type Condition
SecurityException The caller does not have the required permission.


This version of QueueUserWorkItem does not propagate the calling stack onto the worker thread. This allows code to lose the calling stack and thereby elevate its security privileges.

CAUTION   Using UnsafeQueueUserWorkItem could inadvertently open up a security hole. Code access security bases its permission checks on the permissions of all the callers on the stack. When work is queued on a thread pool thread using UnsafeQueueUserWorkItem, the stack of the thread pool thread will not have the context of the actual callers. Malicious code might be able exploit this to avoid permission checks.


Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

.NET Framework Security: 

See Also

ThreadPool Class | ThreadPool Members | System.Threading Namespace | Thread Pooling

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
© 2015 Microsoft