TaskFactory 构造函数

定义

初始化 TaskFactory 类的新实例。Initializes a new instance of the TaskFactory class.

重载

TaskFactory()

使用默认配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the default configuration.

TaskFactory(CancellationToken)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

TaskFactory(TaskScheduler)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

TaskFactory(TaskCreationOptions, TaskContinuationOptions)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

TaskFactory(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

TaskFactory()

使用默认配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the default configuration.

public:
 TaskFactory();
public TaskFactory ();
Public Sub New ()

注解

此构造函数将创建一个 TaskFactory 具有默认配置的实例。This constructor creates a TaskFactory instance with a default configuration. TaskCreationOptions 属性初始化为 None ,并将 TaskContinuationOptions 属性初始化为 None ,并将 TaskScheduler 属性初始化为当前计划程序 (参阅 Current) 。The TaskCreationOptions property is initialized to None, the TaskContinuationOptions property is initialized to None, and the TaskScheduler property is initialized to the current scheduler (see Current).

适用于

TaskFactory(CancellationToken)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

public:
 TaskFactory(System::Threading::CancellationToken cancellationToken);
public TaskFactory (System.Threading.CancellationToken cancellationToken);
new System.Threading.Tasks.TaskFactory : System.Threading.CancellationToken -> System.Threading.Tasks.TaskFactory
Public Sub New (cancellationToken As CancellationToken)

参数

cancellationToken
CancellationToken

将指派给由此 CancellationToken 创建的任务的 TaskFactory,除非在调用工厂方法时显式指定另一个 CancellationToken。The CancellationToken that will be assigned to tasks created by this TaskFactory unless another CancellationToken is explicitly specified while calling the factory methods.

注解

此构造函数将创建一个 TaskFactory 具有默认配置的实例。This constructor creates a TaskFactory instance with a default configuration. TaskCreationOptions 属性初始化为 None ,并将 TaskContinuationOptions 属性初始化为 None ,并将 TaskScheduler 属性初始化为当前计划程序 (参阅 Current) 。The TaskCreationOptions property is initialized to None, the TaskContinuationOptions property is initialized to None, and the TaskScheduler property is initialized to the current scheduler (see Current).

适用于

TaskFactory(TaskScheduler)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

public:
 TaskFactory(System::Threading::Tasks::TaskScheduler ^ scheduler);
public TaskFactory (System.Threading.Tasks.TaskScheduler scheduler);
public TaskFactory (System.Threading.Tasks.TaskScheduler? scheduler);
new System.Threading.Tasks.TaskFactory : System.Threading.Tasks.TaskScheduler -> System.Threading.Tasks.TaskFactory
Public Sub New (scheduler As TaskScheduler)

参数

scheduler
TaskScheduler

要用于计划使用此 TaskFactory 创建的任何任务的 TaskSchedulerThe TaskScheduler to use to schedule any tasks created with this TaskFactory. 一个 null 值,该值指示应使用当前的 TaskScheduler。A null value indicates that the current TaskScheduler should be used.

注解

利用此构造函数,将 TaskCreationOptions 属性初始化为,将属性初始化为, None TaskContinuationOptions None 并将 TaskScheduler 属性初始化为 scheduler ,除非该属性为 null,在这种情况下,将属性初始化为当前计划程序 (参阅 Current) 。With this constructor, the TaskCreationOptions property is initialized to None, the TaskContinuationOptions property is initialized to None, and the TaskScheduler property is initialized to scheduler, unless it's null, in which case the property is initialized to the current scheduler (see Current).

另请参阅

适用于

TaskFactory(TaskCreationOptions, TaskContinuationOptions)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

public:
 TaskFactory(System::Threading::Tasks::TaskCreationOptions creationOptions, System::Threading::Tasks::TaskContinuationOptions continuationOptions);
public TaskFactory (System.Threading.Tasks.TaskCreationOptions creationOptions, System.Threading.Tasks.TaskContinuationOptions continuationOptions);
new System.Threading.Tasks.TaskFactory : System.Threading.Tasks.TaskCreationOptions * System.Threading.Tasks.TaskContinuationOptions -> System.Threading.Tasks.TaskFactory
Public Sub New (creationOptions As TaskCreationOptions, continuationOptions As TaskContinuationOptions)

参数

creationOptions
TaskCreationOptions

在使用此 TaskFactory 创建任务时要使用的默认 TaskCreationOptionsThe default TaskCreationOptions to use when creating tasks with this TaskFactory.

continuationOptions
TaskContinuationOptions

在使用此 TaskFactory 创建延续任务时要使用的默认 TaskContinuationOptionsThe default TaskContinuationOptions to use when creating continuation tasks with this TaskFactory.

例外

creationOptions 参数指定的 TaskCreationOptions 值无效。The creationOptions argument specifies an invalid TaskCreationOptions value. 有关详细信息,请参阅 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的备注。For more information, see the Remarks for FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions).

-or- continuationOptions 参数指定的值无效。The continuationOptions argument specifies an invalid value.

注解

利用此构造函数,将 TaskCreationOptions 属性初始化为 creationOptions ,将 TaskContinuationOptions 属性初始化为 continuationOptions ,并将 TaskScheduler 属性初始化为当前计划程序 (参阅 Current) 。With this constructor, the TaskCreationOptions property is initialized to creationOptions, the TaskContinuationOptions property is initialized to continuationOptions, and the TaskScheduler property is initialized to the current scheduler (see Current).

适用于

TaskFactory(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)

使用指定配置初始化 TaskFactory 实例。Initializes a TaskFactory instance with the specified configuration.

public:
 TaskFactory(System::Threading::CancellationToken cancellationToken, System::Threading::Tasks::TaskCreationOptions creationOptions, System::Threading::Tasks::TaskContinuationOptions continuationOptions, System::Threading::Tasks::TaskScheduler ^ scheduler);
public TaskFactory (System.Threading.CancellationToken cancellationToken, System.Threading.Tasks.TaskCreationOptions creationOptions, System.Threading.Tasks.TaskContinuationOptions continuationOptions, System.Threading.Tasks.TaskScheduler scheduler);
public TaskFactory (System.Threading.CancellationToken cancellationToken, System.Threading.Tasks.TaskCreationOptions creationOptions, System.Threading.Tasks.TaskContinuationOptions continuationOptions, System.Threading.Tasks.TaskScheduler? scheduler);
new System.Threading.Tasks.TaskFactory : System.Threading.CancellationToken * System.Threading.Tasks.TaskCreationOptions * System.Threading.Tasks.TaskContinuationOptions * System.Threading.Tasks.TaskScheduler -> System.Threading.Tasks.TaskFactory
Public Sub New (cancellationToken As CancellationToken, creationOptions As TaskCreationOptions, continuationOptions As TaskContinuationOptions, scheduler As TaskScheduler)

参数

cancellationToken
CancellationToken

默认情况下将指派给由此 CancellationToken 创建的任务的 TaskFactory,除非在调用工厂方法时显式指定另一个 CancellationToken。The default CancellationToken that will be assigned to tasks created by this TaskFactory unless another CancellationToken is explicitly specified while calling the factory methods.

creationOptions
TaskCreationOptions

在使用此 TaskFactory 创建任务时要使用的默认 TaskCreationOptionsThe default TaskCreationOptions to use when creating tasks with this TaskFactory.

continuationOptions
TaskContinuationOptions

在使用此 TaskFactory 创建延续任务时要使用的默认 TaskContinuationOptionsThe default TaskContinuationOptions to use when creating continuation tasks with this TaskFactory.

scheduler
TaskScheduler

要用于计划使用此 TaskFactory 创建的任何任务的默认 TaskSchedulerThe default TaskScheduler to use to schedule any Tasks created with this TaskFactory. 一个 null 值,该值指示应使用 TaskScheduler.Current。A null value indicates that TaskScheduler.Current should be used.

例外

creationOptions 参数指定的 TaskCreationOptions 值无效。The creationOptions argument specifies an invalid TaskCreationOptions value. 有关详细信息,请参阅 FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions) 的备注。For more information, see the Remarks for FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions).

-or- continuationOptions 参数指定的值无效。The continuationOptions argument specifies an invalid value.

注解

利用此构造函数,将 TaskCreationOptions 属性初始化为,将属性初始化为, creationOptions TaskContinuationOptions continuationOptions 并将 TaskScheduler 属性初始化为 scheduler ,除非该属性为 null,在这种情况下,将属性初始化为当前计划程序 (参阅 Current) 。With this constructor, the TaskCreationOptions property is initialized to creationOptions, the TaskContinuationOptions property is initialized to continuationOptions, and the TaskScheduler property is initialized to scheduler, unless it's null, in which case the property is initialized to the current scheduler (see Current).

适用于