Represents a callback method to be executed by a thread pool thread.
Assembly: mscorlib (in mscorlib.dll)
represents a callback method that you want to execute on a ThreadPool thread. Create the delegate by passing your callback method to the constructor. Your method must have the signature shown here.
Queue your task for execution by passing the delegate to ThreadPool.QueueUserWorkItem. Your callback method executes when a thread pool thread becomes available.
Visual Basic users can omit the constructor, and simply use the AddressOf operator when passing the callback method to QueueUserWorkItem. Visual Basic automatically calls the correct delegate constructor.
If you want to pass information to your callback method, create an object that contains the necessary information and pass it to QueueUserWorkItem when you queue your task for execution. Each time your callback method executes, the state parameter contains this object.
For more information about using callbacks to synchronize thread pool threads, see The Managed Thread Pool.
This section contains two examples. The first example demonstrates how you can queue a simple task for execution by the thread pool.
The second example demonstrates how you can queue a task and pass information to it.
This example shows how to use the delegate to queue a task for execution by the thread pool. The code example uses the ThreadPool.QueueUserWorkItem(WaitCallback) method overload to queue a task, which is represented by a that wraps the ThreadProc method, to execute when a thread becomes available. No task information is supplied with this overload. Therefore, the information that is available to the ThreadProc method is limited to the object the method belongs to.
This example shows how to create an object that contains task information. It also demonstrates how to pass that object to a task that is queued for execution by the thread pool.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.