Allows access to the thread pool. See Using the thread pool in Windows Store apps for detailed guidance on using the thread pool:
- Quickstart: Submitting a work item to the thread pool
- How to submit a work item using a timer
- How to create a periodic work item
- How to create and use pre-allocated work items
- Best practices for using the thread pool
- How to respond to named events and semaphores
- How to use functions as work item delegates
Note The ThreadPool API is supported for desktop as well as Windows Store apps.
The ThreadPool class has these types of members:
The ThreadPool class has these methods. It also inherits methods from the Object class.
|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.|
The ThreadPool class has only static methods, so its methods can be called without creating an instance of the class.
The following code shows the creation of a work item by passing in a WorkItemHandler delegate method. The delegate method should periodically check the Canceled property of the operation parameter, and exit gracefully if the work item has been cancelled.
IAsyncAction WorkItem = Windows.System.Threading.ThreadPool.RunAsync(ExampleWorkItemHandler, WorkItemPriority.Normal);
Minimum supported client
|Windows 8 [Windows Store apps only]|
Minimum supported server
|Windows Server 2012 [Windows Store apps only]|
Minimum supported phone
|Windows Phone 8|
Build date: 11/16/2013