WorkItemHandler WorkItemHandler WorkItemHandler WorkItemHandler Delegate


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

public : delegate void WorkItemHandler(IAsyncAction operation)
struct WorkItemHandler : winrt::Windows::Foundation::IUnknown
   WorkItemHandler(std::nullptr_t = nullptr) noexcept;
   template <typename L> WorkItemHandler(L lambda);
   template <typename F> WorkItemHandler(F* function);
   template <typename O, typename M> WorkItemHandler(O* object, M method);
   void operator()(winrt::Windows::Foundation::IAsyncAction const& operation) const;
public delegate void WorkItemHandler(IAsyncAction operation)
Public Delegate Sub WorkItemHandler(operation As IAsyncAction)


IAsyncAction IAsyncAction

The work item to associate with the callback method.


Windows 10 requirements

Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


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.