共用方式為


PreallocatedWorkItem 類別

定義

預先配置的工作專案會在提交至執行緒集區之前建構,確保已建構工作專案,以便在必要時提交至執行緒集區。 例如,如果資源解除配置常式需要預先配置WorkItem,則可以建立 PreallocatedWorkItem,因為資源解除配置常式可能會在沒有足夠的資源可供建立工作專案的情況下呼叫。

注意

桌面和 UWP 應用程式都支援 ThreadPool API。

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
繼承
Object Platform::Object IInspectable PreallocatedWorkItem
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

建構函式

PreallocatedWorkItem(WorkItemHandler)

使用 WorkItemHandler 委派初始化新的工作專案,並事先配置工作專案的資源。

PreallocatedWorkItem(WorkItemHandler, WorkItemPriority)

使用 WorkItemHandler 委派初始化新的工作專案、事先配置工作專案的資源,以及指定工作專案相對於執行緒集區中其他工作專案的優先順序。

PreallocatedWorkItem(WorkItemHandler, WorkItemPriority, WorkItemOptions)

使用 WorkItemHandler 委派初始化新的工作專案、事先配置工作專案的資源,以及指定工作專案相對於執行緒集區中其他工作專案的優先順序。 也指定執行緒集區如何配置工作專案的處理器時間。

方法

RunAsync()

將預先配置的工作專案提交至執行緒集區,而不需要配置任何其他資源。

適用於