TaskFactory 類別

定義

提供建立和排程 Task 物件的支援。Provides support for creating and scheduling Task objects.

public ref class TaskFactory
public class TaskFactory
type TaskFactory = class
Public Class TaskFactory
繼承
TaskFactory

範例

下列範例會使用 static Factory 屬性對 TaskFactory.StartNew 方法進行兩個呼叫。The following example uses the static Factory property to make two calls to the TaskFactory.StartNew method. 第一個會以使用者的 MyDocuments 目錄中的檔案名填入陣列,第二個則會在陣列中填入使用者 MyDocuments 目錄的子目錄名稱。The first populates an array with the names of files in the user's MyDocuments directory, while the second populates an array with the names of subdirectories of the user's MyDocuments directory. 接著,它會呼叫 TaskFactory.ContinueWhenAll(Task[], Action<Task[]>) 方法,在前兩個工作完成執行之後,顯示兩個數組中檔案和目錄數目的相關資訊。It then calls the TaskFactory.ContinueWhenAll(Task[], Action<Task[]>) method, which displays information about the number of files and directories in the two arrays after the first two tasks have completed execution.

using System;
using System.IO;
using System.Threading.Tasks;

public class Example
{
   public static void Main()
   {
      Task[] tasks = new Task[2];
      String[] files = null;
      String[] dirs = null;
      String docsDirectory = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

      tasks[0] = Task.Factory.StartNew( () => files = Directory.GetFiles(docsDirectory));
      tasks[1] = Task.Factory.StartNew( () => dirs = Directory.GetDirectories(docsDirectory));

      Task.Factory.ContinueWhenAll(tasks, completedTasks => {
                                             Console.WriteLine("{0} contains: ", docsDirectory);
                                             Console.WriteLine("   {0} subdirectories", dirs.Length);
                                             Console.WriteLine("   {0} files", files.Length);
                                          } );
   }
}
// The example displays output like the following:
//       C:\Users\<username>\Documents contains:
//          24 subdirectories
//          16 files
Imports System.IO
Imports System.Threading.Tasks

Module Example
   Public Sub Main()
      Dim tasks(1) As Task
      Dim files() As String = Nothing
      Dim dirs() As String = Nothing
      Dim docsDirectory As String = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
      
      tasks(0) = Task.Factory.StartNew( Sub()
                                           files = Directory.GetFiles(docsDirectory)
                                        End Sub )
      tasks(1) = Task.Factory.StartNew( Sub()
                                           dirs = Directory.GetDirectories(docsDirectory)
                                        End Sub )
      Task.Factory.ContinueWhenAll(tasks, Sub(completedTasks)
                                             Console.WriteLine("{0} contains: ", docsDirectory)
                                             Console.WriteLine("   {0} subdirectories", dirs.Length)
                                             Console.WriteLine("   {0} files", files.Length)
                                          End Sub)
   End Sub
End Module
' The example displays output like the following:
'       C:\Users\<username>\Documents contains:
'          24 subdirectories
'          16 files

備註

.NET Framework 提供建立和排程工作的兩個工廠:The .NET Framework provides two factories for creating and scheduling tasks:

  • @No__t-0 類別,它會建立 Task 和 @no__t 2 物件。The TaskFactory class, which creates Task and Task<TResult> objects. 您可以呼叫這個方法的多載,以建立和執行需要非預設引數的工作。You can call the overloads of this method to create and execute a task that requires non-default arguments.

    警告

    .NET Framework 4.5.NET Framework 4.5 開始,@no__t 1 方法提供最簡單的方式來建立具有預設設定值的工作,並立即啟動它。Starting with the .NET Framework 4.5.NET Framework 4.5, the Task.Run method provides the easiest way to create a task with default configuration values and start it immediately.

  • @No__t-0 類別,它會建立 @no__t 1 的物件。The TaskFactory<TResult> class, which creates Task<TResult> objects.

[@No__t-0] 類別可讓您執行下列動作:The TaskFactory class allows you to do the following:

  • 建立工作,並藉由呼叫 StartNew 方法立即啟動它。Create a task and start it immediately by calling the StartNew method.

    警告

    .NET Framework 4.5.NET Framework 4.5 開始,@no__t 1 方法提供最簡單的方式來建立具有預設設定值的工作,並立即啟動它。Starting with the .NET Framework 4.5.NET Framework 4.5, the Task.Run method provides the easiest way to create a task with default configuration values and start it immediately.

  • 藉由呼叫 ContinueWhenAny 方法,建立一個在陣列中的任何工作完成時啟動的工作。Create a task that starts when any one of the tasks in an array has completed by calling the ContinueWhenAny method.

  • 建立一個工作,當陣列中的所有工作都已完成時,就會呼叫 ContinueWhenAll 方法來啟動。Create a task that starts when all the tasks in an array have completed by calling the ContinueWhenAll method.

Static Task<TResult>.Factory 屬性會傳回預設的 TaskFactory<TResult> 物件。The static Task<TResult>.Factory property returns a default TaskFactory<TResult> object. 您也可以呼叫其中一個 TaskFactory 類別的函式,以設定 @no__t 2 類別所建立的 @no__t 1 物件。You can also call one of the TaskFactory class constructors to configure the Task objects that the TaskFactory class creates. 下列範例會設定新的 TaskFactory 物件,以建立具有指定的解除標記、工作建立選項、接續選項和自訂工作排程器的工作。The following example configures a new TaskFactory object to create tasks that have a specified cancellation token, task creation options, continuation options, and a customized task scheduler.

using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

class Example
{
   static CancellationTokenSource cts = new CancellationTokenSource();
   
   static TaskFactory factory = new TaskFactory(
      cts.Token,
      TaskCreationOptions.PreferFairness,
      TaskContinuationOptions.ExecuteSynchronously,
      new CustomScheduler());

   static void Main()
   {
      var t2 = factory.StartNew(() => DoWork());
      cts.Dispose();
   }

   static void DoWork() {/*...*/ }
}
Imports System.Collections.Generic
Imports System.Threading
Imports System.Threading.Tasks

Module Example
   Public Sub Main()
      Dim cts As New CancellationTokenSource()
      Dim factory As New TaskFactory(cts.Token,
                                     TaskCreationOptions.PreferFairness,
                                     TaskContinuationOptions.ExecuteSynchronously,
                                     New CustomScheduler())

      Dim t2 = factory.StartNew(Sub() DoWork())
      cts.Dispose()
   End Sub

   Sub DoWork()
      ' ...
   End Sub
End Module

在大部分的情況下,您不需要具現化新的 TaskFactory 實例。In most cases, you do not have to instantiate a new TaskFactory instance. 相反地,您可以使用 Task.Factory 屬性,它會傳回使用預設值的 factory 物件。Instead, you can use the Task.Factory property, which returns a factory object that uses default values. 接著,您可以呼叫其方法來啟動新的工作或定義工作接續。You can then call its methods to start new tasks or define task continuations. 如需圖例,請參閱範例。For an illustration, see the example.

建構函式

TaskFactory()

使用預設組態,初始化 TaskFactory 執行個體。Initializes a TaskFactory instance with the default configuration.

TaskFactory(CancellationToken)

使用指定的組態,初始化 TaskFactory 執行個體。Initializes a TaskFactory instance with the specified configuration.

TaskFactory(CancellationToken, TaskCreationOptions, TaskContinuationOptions, TaskScheduler)

使用指定的組態,初始化 TaskFactory 執行個體。Initializes a TaskFactory instance with the specified configuration.

TaskFactory(TaskCreationOptions, TaskContinuationOptions)

使用指定的組態,初始化 TaskFactory 執行個體。Initializes a TaskFactory instance with the specified configuration.

TaskFactory(TaskScheduler)

使用指定的組態,初始化 TaskFactory 執行個體。Initializes a TaskFactory instance with the specified configuration.

屬性

CancellationToken

取得這個工作 Factory 的預設取消語彙基元。Gets the default cancellation token for this task factory.

ContinuationOptions

取得這個工作 Factory 的預設工作接續選項。Gets the default task continuation options for this task factory.

CreationOptions

取得這個工作 Factory 的預設工作建立選項。Gets the default task creation options for this task factory.

Scheduler

取得這個工作 Factory 的預設工作排程器。Gets the default task scheduler for this task factory.

方法

ContinueWhenAll(Task[], Action<Task[]>)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll(Task[], Action<Task[]>, CancellationToken)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll(Task[], Action<Task[]>, CancellationToken, TaskContinuationOptions, TaskScheduler)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll(Task[], Action<Task[]>, TaskContinuationOptions)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[],TResult>)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[],TResult>, CancellationToken)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[],TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>[],TResult>, TaskContinuationOptions)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>[]>)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>[]>, CancellationToken)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>[]>, CancellationToken, TaskContinuationOptions, TaskScheduler)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>[]>, TaskContinuationOptions)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TResult>(Task[], Func<Task[],TResult>)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TResult>(Task[], Func<Task[],TResult>, CancellationToken)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TResult>(Task[], Func<Task[],TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAll<TResult>(Task[], Func<Task[],TResult>, TaskContinuationOptions)

當一組指定的工作已完成時,建立啟動的接續工作。Creates a continuation task that starts when a set of specified tasks has completed.

ContinueWhenAny(Task[], Action<Task>)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny(Task[], Action<Task>, CancellationToken)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny(Task[], Action<Task>, CancellationToken, TaskContinuationOptions, TaskScheduler)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny(Task[], Action<Task>, TaskContinuationOptions)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>,TResult>)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>,TResult>, CancellationToken)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>,TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult,TResult>(Task<TAntecedentResult>[], Func<Task<TAntecedentResult>,TResult>, TaskContinuationOptions)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>>)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>>, CancellationToken)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>>, CancellationToken, TaskContinuationOptions, TaskScheduler)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TAntecedentResult>(Task<TAntecedentResult>[], Action<Task<TAntecedentResult>>, TaskContinuationOptions)

建立會在提供的任何一項工作完成時啟動的 TaskCreates a continuation Task that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TResult>(Task[], Func<Task,TResult>)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TResult>(Task[], Func<Task,TResult>, CancellationToken)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TResult>(Task[], Func<Task,TResult>, CancellationToken, TaskContinuationOptions, TaskScheduler)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

ContinueWhenAny<TResult>(Task[], Func<Task,TResult>, TaskContinuationOptions)

建立會在提供的任何一項工作完成時啟動的 Task<TResult>Creates a continuation Task<TResult> that will be started upon the completion of any Task in the provided set.

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync(Func<AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, Object, TaskCreationOptions)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync(IAsyncResult, Action<IAsyncResult>)

建立 Task,這個項目會在指定的 IAsyncResult 完成時執行結束方法動作。Creates a Task that executes an end method action when a specified IAsyncResult completes.

FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions)

建立 Task,這個項目會在指定的 IAsyncResult 完成時執行結束方法動作。Creates a Task that executes an end method action when a specified IAsyncResult completes.

FromAsync(IAsyncResult, Action<IAsyncResult>, TaskCreationOptions, TaskScheduler)

建立 Task,這個項目會在指定的 IAsyncResult 完成時執行結束方法動作。Creates a Task that executes an end method action when a specified IAsyncResult completes.

FromAsync<TArg1,TArg2,TArg3,TResult>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2,TArg3,TResult>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, TArg3, Object)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2,TArg3>(Func<TArg1,TArg2,TArg3,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, TArg3, Object, TaskCreationOptions)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2,TResult>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2,TResult>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, TArg2, Object, TaskCreationOptions)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, Object)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TArg2>(Func<TArg1,TArg2,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, TArg2, Object, TaskCreationOptions)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TResult>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1,TResult>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, TArg1, Object, TaskCreationOptions)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, Object)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TArg1>(Func<TArg1,AsyncCallback,Object,IAsyncResult>, Action<IAsyncResult>, TArg1, Object, TaskCreationOptions)

建立 Task,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TResult>(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TResult>(Func<AsyncCallback,Object,IAsyncResult>, Func<IAsyncResult,TResult>, Object, TaskCreationOptions)

建立 Task<TResult>,表示一組符合「非同步程式設計模型」模式的開始和結束方法。Creates a Task<TResult> that represents a pair of begin and end methods that conform to the Asynchronous Programming Model pattern.

FromAsync<TResult>(IAsyncResult, Func<IAsyncResult,TResult>)

建立 Task<TResult>,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a Task<TResult> that executes an end method function when a specified IAsyncResult completes.

FromAsync<TResult>(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions)

建立 Task<TResult>,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a Task<TResult> that executes an end method function when a specified IAsyncResult completes.

FromAsync<TResult>(IAsyncResult, Func<IAsyncResult,TResult>, TaskCreationOptions, TaskScheduler)

建立 Task<TResult>,當指定的 IAsyncResult 完成時會執行結束方法函式。Creates a Task<TResult> that executes an end method function when a specified IAsyncResult completes.

GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複本 (Shallow Copy)。Creates a shallow copy of the current Object.

(繼承來源 Object)
StartNew(Action)

建立並啟動工作。Creates and starts a task.

StartNew(Action, CancellationToken)

建立並啟動 TaskCreates and starts a Task.

StartNew(Action, CancellationToken, TaskCreationOptions, TaskScheduler)

建立並啟動 TaskCreates and starts a Task.

StartNew(Action, TaskCreationOptions)

建立並啟動 TaskCreates and starts a Task.

StartNew(Action<Object>, Object)

建立並啟動 TaskCreates and starts a Task.

StartNew(Action<Object>, Object, CancellationToken)

建立並啟動 TaskCreates and starts a Task.

StartNew(Action<Object>, Object, CancellationToken, TaskCreationOptions, TaskScheduler)

建立並啟動 TaskCreates and starts a Task.

StartNew(Action<Object>, Object, TaskCreationOptions)

建立並啟動 TaskCreates and starts a Task.

StartNew<TResult>(Func<Object,TResult>, Object)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<Object,TResult>, Object, CancellationToken)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<Object,TResult>, Object, CancellationToken, TaskCreationOptions, TaskScheduler)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<Object,TResult>, Object, TaskCreationOptions)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<TResult>)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<TResult>, CancellationToken)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<TResult>, CancellationToken, TaskCreationOptions, TaskScheduler)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

StartNew<TResult>(Func<TResult>, TaskCreationOptions)

建立並啟動 Task<TResult>Creates and starts a Task<TResult>.

ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)

適用於

執行緒安全性

@No__t-0 的所有 public 和 protected 成員都是安全線程,而且可以從多個執行緒同時使用。All public and protected members of TaskFactory are thread-safe and may be used concurrently from multiple threads.

另請參閱