Share via


WorkItemHandler Delegate

Definition

Represents a method that is called when a work item runs.

public delegate void WorkItemHandler(IAsyncAction ^ operation);
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Guid(488278923, 64102, 16719, 156, 189, 182, 95, 201, 157, 23, 250)]
class WorkItemHandler : MulticastDelegate
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Guid(488278923, 64102, 16719, 156, 189, 182, 95, 201, 157, 23, 250)]
public delegate void WorkItemHandler(IAsyncAction operation);
Public Delegate Sub WorkItemHandler(operation As IAsyncAction)

Parameters

operation
IAsyncAction

The work item to associate with the callback method.

Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Remarks

The thread pool calls a work item's WorkItemHandler delegate when a thread becomes available to run the work item. If a work item is canceled, WorkItemHandler delegates that have not yet started running are not called. WorkItemHandler delegates that are already running are allowed to finish unless the application stops them. If a work item might run for a relatively long time, the application should check if cancellation has been requested and stop the handler in an orderly way.

For an example, see Submit a work item to the thread pool.

Applies to