PreallocatedWorkItem Class

Definition

A preallocated work item is constructed in advance of its submission to the thread pool, ensuring that the work item is constructed so that it can be submitted to the thread pool when necessary. For example, a PreallocatedWorkItem can be created in case it is needed for a resource deallocation routine, since the resource deallocation routine may be called in circumstances when not enough resources would be available to create the work item.

Note

The ThreadPool API is supported for desktop as well as UWP apps.

public ref class PreallocatedWorkItem sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.System.Threading.Core.IPreallocatedWorkItemFactory, 65536, Windows.Foundation.UniversalApiContract)]
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class PreallocatedWorkItem final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
/// [Windows.Foundation.Metadata.Activatable(Windows.System.Threading.Core.IPreallocatedWorkItemFactory, 65536, "Windows.Foundation.UniversalApiContract")]
class PreallocatedWorkItem final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.System.Threading.Core.IPreallocatedWorkItemFactory), 65536, typeof(Windows.Foundation.UniversalApiContract))]
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class PreallocatedWorkItem
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.System.Threading.Core.IPreallocatedWorkItemFactory), 65536, "Windows.Foundation.UniversalApiContract")]
public sealed class PreallocatedWorkItem
Public NotInheritable Class PreallocatedWorkItem
Inheritance
Object Platform::Object IInspectable PreallocatedWorkItem
Attributes

Windows requirements

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

Constructors

PreallocatedWorkItem(WorkItemHandler, WorkItemPriority, WorkItemOptions)

Initializes a new work item with a WorkItemHandler delegate, allocating resources for the work item in advance, and specifies the priority of the work item relative to other work items in the thread pool. Also specifies how the thread pool will allocate processor time for the work item.

PreallocatedWorkItem(WorkItemHandler, WorkItemPriority)

Initializes a new work item with a WorkItemHandler delegate, allocating resources for the work item in advance, and specifies the priority of the work item relative to other work items in the thread pool.

PreallocatedWorkItem(WorkItemHandler)

Initializes a new work item with a WorkItemHandler delegate, allocating resources for the work item in advance.

Methods

RunAsync()

Submits the preallocated work item to the thread pool, without requiring any additional resources to be allocated.

Applies to