WaitCallback WaitCallback WaitCallback WaitCallback Delegate

Definition

Represents a callback method to be executed by a thread pool thread.

public delegate void WaitCallback(System::Object ^ state);
[System.Runtime.InteropServices.ComVisible(true)]
public delegate void WaitCallback(object state);
type WaitCallback = delegate of obj -> unit
Public Delegate Sub WaitCallback(state As Object)
Parameters
state
Object Object Object Object

An object containing information to be used by the callback method.

Inheritance
WaitCallbackWaitCallbackWaitCallbackWaitCallback
Attributes

Remarks

WaitCallback represents a callback method that you want to execute on a ThreadPool thread. Create the delegate by passing your callback method to the WaitCallback constructor. Your method must have the signature shown here.

Queue the method for execution by passing the WaitCallback delegate to ThreadPool.QueueUserWorkItem. The callback method executes when a thread pool thread becomes available.

Note

Visual Basic users can omit the WaitCallback 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 the callback method, create an object that contains the necessary information and pass it to the QueueUserWorkItem(WaitCallback, Object) method as the second argument. Each time the callback method executes, the state parameter contains this object.

For examples that use the WaitCallback delegate, see the ThreadPool.QueueUserWorkItem method.

For more information about the thread pool, see The managed thread pool.

Applies to

See Also