PreallocatedWorkItem PreallocatedWorkItem PreallocatedWorkItem Class

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 Windows Store apps.

Syntax

Declaration

public sealed class PreallocatedWorkItempublic sealed class PreallocatedWorkItemPublic NotInheritable Class PreallocatedWorkItem

Constructors summary

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

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.

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.

Methods summary

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

Constructors

  • PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler)

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

    public PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler handler)public PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler handler)Public Function PreallocatedWorkItem(handler As Windows.System.Threading.WorkItemHandler) As

    Parameters

    Remarks

    In C++, make sure that methods used as WorkItemHandler delegates exhibit agile threading model behavior. Calling a non-agile method from a work item will cause a deadlock to occur.

  • PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.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.

    public PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler handler,Windows.System.Threading.WorkItemPriority priority)public PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler handler,Windows.System.Threading.WorkItemPriority priority)Public Function PreallocatedWorkItem(handler As Windows.System.Threading.WorkItemHandler,priority As Windows.System.Threading.WorkItemPriority) As

    Parameters

    Remarks

    See the remarks section of the @Windows.System.Threading.Core.PreallocatedWorkItem.#ctor(Windows.System.Threading.WorkItemHandler) overload.

  • PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority,Windows.System.Threading.WorkItemOptions)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority,Windows.System.Threading.WorkItemOptions)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority,Windows.System.Threading.WorkItemOptions)
    PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler,Windows.System.Threading.WorkItemPriority,Windows.System.Threading.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.

    public PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler handler,Windows.System.Threading.WorkItemPriority priority,Windows.System.Threading.WorkItemOptions options)public PreallocatedWorkItem(Windows.System.Threading.WorkItemHandler handler,Windows.System.Threading.WorkItemPriority priority,Windows.System.Threading.WorkItemOptions options)Public Function PreallocatedWorkItem(handler As Windows.System.Threading.WorkItemHandler,priority As Windows.System.Threading.WorkItemPriority,options As Windows.System.Threading.WorkItemOptions) As

    Parameters

    Remarks

    See the remarks section of the @Windows.System.Threading.Core.PreallocatedWorkItem.#ctor(Windows.System.Threading.WorkItemHandler) overload.

Methods

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ActivatableAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.System.Threading.Core.dll