PreallocatedWorkItem 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
预先分配的工作项是在提交到线程池之前构造的,确保已构造工作项,以便在必要时将其提交到线程池。 例如,如果资源解除分配例程需要 PreallocatedWorkItem,则可以创建 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
- 继承
- 属性
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() |
将预先分配的工作项提交到线程池,而无需分配任何其他资源。 |