System.Threading.ThreadPool.QueueUserWorkItem Method

Queues a method for execution. The method executes when a thread pool thread becomes available.

Syntax

public static bool QueueUserWorkItem (WaitCallback callBack)

Parameters

callBack
A System.Threading.WaitCallback that represents the method to be executed.

Returns

true if the method is successfully queued; NotSupportedException is thrown if the work item could not be queued.

Remarks

You can place data required by the queued method in the instance fields of the class in which the method is defined, or you can use the ThreadPool.QueueUserWorkItem(WaitCallback, object) overload that accepts an object containing the necessary data.

Note:

Visual Basic users can omit the System.Threading.WaitCallback constructor, and simply use the AddressOf operator when passing the callback method to ThreadPool.QueueUserWorkItem(WaitCallback, object). Visual Basic automatically calls the correct delegate constructor.

Version Information

In the .NET Framework version 2.0, the Thread.CurrentPrincipal property value is propagated to worker threads queued using the erload:System.Threading.ThreadPool.QueueUserWorkItem method. In earlier versions, the principal information is not propagated.

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0