ThreadPool class

Applies to Windows and Windows Phone

Allows access to the thread pool. See Using the thread pool in Windows Store apps for detailed guidance on using the thread pool:

Note  The ThreadPool API is supported for desktop as well as Windows Store apps.

Syntax

Public NotInheritable Class ThreadPool

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

Members

The ThreadPool class has these types of members:

Methods

The ThreadPool class has these methods. It also inherits methods from the Object class.

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 ThreadPool class has only static methods, so its methods can be called without creating an instance of the class.

Examples

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);

Requirements

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

Namespace

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

Metadata

Windows.winmd

 

 

Show:
© 2014 Microsoft. All rights reserved.