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 [C#] public static bool UnsafeQueueUserWorkItem( WaitCallback callBack, object state ); [C++] public: static bool UnsafeQueueUserWorkItem( WaitCallback* callBack, Object* state ); [JScript] 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.
true if the method succeeds; otherwise, false.
|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:
- SecurityPermission to provide evidence and view and modify policy. Associated enumerations: SecurityPermissionFlag.ControlEvidence, SecurityPermissionFlag.ControlPolicy.