ThreadPool.RunAsync methods

Applies to Windows and Windows Phone

Creates work items to be submitted to the thread pool.

Overload list

MethodDescription
RunAsync(WorkItemHandler) Creates a work item.
RunAsync(WorkItemHandler, WorkItemPriority) Creates a work item and specifies its priority relative to other work items in the thread pool.
RunAsync(WorkItemHandler, WorkItemPriority, WorkItemOptions) Creates a work item, specifies its priority relative to other work items in the thread pool, and specifies how long-running work items should be run.

Remarks

The RunAsync method creates a work item and returns an IAsyncAction interface that provides access to the work item. The following table describes how IAsyncAction and IAsyncInfo properties and methods apply to thread pool work items.

Property or MethodDescription
IAsyncAction.Completed Gets or sets the method that handles the completed event for a work item.
IAsyncAction.GetResults This method does not perform any action for the thread pool. The work item's WorkItemHandler delegate is responsible for providing the results of a work item to the application.
IAsyncInfo.Cancel Cancels a work item and sets its Status property to cancelled. If the work item's WorkItemHandler delegate is not already running, the delegate is not called. If the WorkItemHandler delegate is already running, it continues to run unless the application stops it. Canceling a work item triggers its completion event.
IAsyncInfo.Close Releases a work item when it is no longer needed. Close should be called only if the work item's Status property is cancelled, completed, or error.
IAsyncInfo.ErrorCode Gets a string that describes the error condition of a work item.
IAsyncInfo.Id Gets the unique identifier of a work item. The thread pool assigns this identifier when the work item is created. Work item identifiers are not recycled while the system is running.
IAsyncInfo.Status Gets an AsyncStatus value that indicates the status of a work item.

 

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8

Namespace

Windows.System.Threading
Windows::System::Threading [C++]

Metadata

Windows.winmd

See also

ThreadPool

 

 

Show:
© 2014 Microsoft