TaskFactory<TResult>.ContinueWhenAny 方法

定義

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

多載

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

public:
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task ^> ^ tasks, Func<System::Threading::Tasks::Task ^, TResult> ^ continuationFunction, System::Threading::CancellationToken cancellationToken, System::Threading::Tasks::TaskContinuationOptions continuationOptions, System::Threading::Tasks::TaskScheduler ^ scheduler);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task,TResult> continuationFunction, System.Threading.CancellationToken cancellationToken, System.Threading.Tasks.TaskContinuationOptions continuationOptions, System.Threading.Tasks.TaskScheduler scheduler);
member this.ContinueWhenAny : System.Threading.Tasks.Task[] * Func<System.Threading.Tasks.Task, 'Result> * System.Threading.CancellationToken * System.Threading.Tasks.TaskContinuationOptions * System.Threading.Tasks.TaskScheduler -> System.Threading.Tasks.Task<'Result>

參數

tasks
Task[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的取消語彙基元。The cancellation token that will be assigned to the new continuation task.

continuationOptions
TaskContinuationOptions

其中一個列舉值,這些值會控制已建立之接續工作的行為。One of the enumeration values that controls the behavior of the created continuation task. NotOn*OnlyOn* 值無效。The NotOn* and OnlyOn* values are not valid.

scheduler
TaskScheduler

用來排定所建立之接續工作的工作排程器。The task scheduler that is used to schedule the created continuation task.

傳回

新的接續工作。The new continuation task.

例外狀況

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

-或--or- scheduler 引數為 nullThe scheduler argument is null.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

continuationOptions 引數指定了無效的 TaskContinuationOptions 值。The continuationOptions argument specifies an invalid TaskContinuationOptions value.

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

-或--or- 已處置建立 CancellationTokenSourcecancellationTokenThe CancellationTokenSource that created cancellationToken has already been disposed.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task ^> ^ tasks, Func<System::Threading::Tasks::Task ^, TResult> ^ continuationFunction);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task,TResult> continuationFunction);
member this.ContinueWhenAny : System.Threading.Tasks.Task[] * Func<System.Threading.Tasks.Task, 'Result> -> System.Threading.Tasks.Task<'Result>
Public Function ContinueWhenAny (tasks As Task(), continuationFunction As Func(Of Task, TResult)) As Task(Of TResult)

參數

tasks
Task[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

傳回

新的接續工作。The new continuation task.

例外狀況

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

tasks 陣列包含 null 值或為空白。The tasks array contains a null value or is empty.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task ^> ^ tasks, Func<System::Threading::Tasks::Task ^, TResult> ^ continuationFunction, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task,TResult> continuationFunction, System.Threading.CancellationToken cancellationToken);
member this.ContinueWhenAny : System.Threading.Tasks.Task[] * Func<System.Threading.Tasks.Task, 'Result> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>

參數

tasks
Task[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的取消語彙基元。The cancellation token that will be assigned to the new continuation task.

傳回

新的接續工作。The new continuation task.

例外狀況

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

-或--or- 已處置建立 CancellationTokenSourcecancellationTokenThe CancellationTokenSource that created cancellationToken has already been disposed.

tasks 陣列為 null。The tasks array is null.

-或--or- continuationFunction 引數為 null。The continuationFunction argument is null.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task ^> ^ tasks, Func<System::Threading::Tasks::Task ^, TResult> ^ continuationFunction, System::Threading::Tasks::TaskContinuationOptions continuationOptions);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task,TResult> continuationFunction, System.Threading.Tasks.TaskContinuationOptions continuationOptions);
member this.ContinueWhenAny : System.Threading.Tasks.Task[] * Func<System.Threading.Tasks.Task, 'Result> * System.Threading.Tasks.TaskContinuationOptions -> System.Threading.Tasks.Task<'Result>
Public Function ContinueWhenAny (tasks As Task(), continuationFunction As Func(Of Task, TResult), continuationOptions As TaskContinuationOptions) As Task(Of TResult)

參數

tasks
Task[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

continuationOptions
TaskContinuationOptions

其中一個列舉值,這些值會控制已建立之接續工作的行為。One of the enumeration values that controls the behavior of the created continuation task. NotOn*OnlyOn* 值無效。The NotOn* and OnlyOn* values are not valid.

傳回

新的接續工作。The new continuation task.

例外狀況

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

continuationOptions 引數指定了無效的列舉值。The continuationOptions argument specifies an invalid enumeration value.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
generic <typename TAntecedentResult>
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task<TAntecedentResult> ^> ^ tasks, Func<System::Threading::Tasks::Task<TAntecedentResult> ^, TResult> ^ continuationFunction, System::Threading::CancellationToken cancellationToken, System::Threading::Tasks::TaskContinuationOptions continuationOptions, System::Threading::Tasks::TaskScheduler ^ scheduler);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>,TResult> continuationFunction, System.Threading.CancellationToken cancellationToken, System.Threading.Tasks.TaskContinuationOptions continuationOptions, System.Threading.Tasks.TaskScheduler scheduler);
member this.ContinueWhenAny : System.Threading.Tasks.Task<'AntecedentResult>[] * Func<System.Threading.Tasks.Task<'AntecedentResult>, 'Result> * System.Threading.CancellationToken * System.Threading.Tasks.TaskContinuationOptions * System.Threading.Tasks.TaskScheduler -> System.Threading.Tasks.Task<'Result>

類型參數

TAntecedentResult

前項 tasks 的結果類型。The type of the result of the antecedent tasks.

參數

tasks
Task<TAntecedentResult>[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的取消語彙基元。The cancellation token that will be assigned to the new continuation task.

continuationOptions
TaskContinuationOptions

其中一個列舉值,這些值會控制已建立之接續工作的行為。One of the enumeration values that controls the behavior of the created continuation task. NotOn*OnlyOn* 值無效。The NotOn* and OnlyOn* values are not valid.

scheduler
TaskScheduler

TaskScheduler,用來排定建立的接續 Task<TResult>The TaskScheduler that is used to schedule the created continuation Task<TResult>.

傳回

新的接續 Task<TResult>The new continuation Task<TResult>.

例外狀況

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

-或--or- scheduler 引數為 null。The scheduler argument is null.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

continuationOptions 引數指定了無效的 TaskContinuationOptions 值。The continuationOptions argument specifies an invalid TaskContinuationOptions value.

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

-或--or- 已處置建立 CancellationTokenSourcecancellationTokenThe CancellationTokenSource that created cancellationToken has already been disposed.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
generic <typename TAntecedentResult>
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task<TAntecedentResult> ^> ^ tasks, Func<System::Threading::Tasks::Task<TAntecedentResult> ^, TResult> ^ continuationFunction, System::Threading::Tasks::TaskContinuationOptions continuationOptions);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>,TResult> continuationFunction, System.Threading.Tasks.TaskContinuationOptions continuationOptions);
member this.ContinueWhenAny : System.Threading.Tasks.Task<'AntecedentResult>[] * Func<System.Threading.Tasks.Task<'AntecedentResult>, 'Result> * System.Threading.Tasks.TaskContinuationOptions -> System.Threading.Tasks.Task<'Result>
Public Function ContinueWhenAny(Of TAntecedentResult) (tasks As Task(Of TAntecedentResult)(), continuationFunction As Func(Of Task(Of TAntecedentResult), TResult), continuationOptions As TaskContinuationOptions) As Task(Of TResult)

類型參數

TAntecedentResult

前項 tasks 的結果類型。The type of the result of the antecedent tasks.

參數

tasks
Task<TAntecedentResult>[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

continuationOptions
TaskContinuationOptions

其中一個列舉值,這些值會控制已建立之接續工作的行為。One of the enumeration values that controls the behavior of the created continuation task. NotOn*OnlyOn* 值無效。The NotOn* and OnlyOn* values are not valid.

傳回

新的接續 Task<TResult>The new continuation Task<TResult>.

例外狀況

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

continuationOptions 引數指定了無效的列舉值。The continuationOptions argument specifies an invalid enumeration value.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
generic <typename TAntecedentResult>
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task<TAntecedentResult> ^> ^ tasks, Func<System::Threading::Tasks::Task<TAntecedentResult> ^, TResult> ^ continuationFunction);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>,TResult> continuationFunction);
member this.ContinueWhenAny : System.Threading.Tasks.Task<'AntecedentResult>[] * Func<System.Threading.Tasks.Task<'AntecedentResult>, 'Result> -> System.Threading.Tasks.Task<'Result>
Public Function ContinueWhenAny(Of TAntecedentResult) (tasks As Task(Of TAntecedentResult)(), continuationFunction As Func(Of Task(Of TAntecedentResult), TResult)) As Task(Of TResult)

類型參數

TAntecedentResult

前項 tasks 的結果類型。The type of the result of the antecedent tasks.

參數

tasks
Task<TAntecedentResult>[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

傳回

新的接續 Task<TResult>The new continuation Task<TResult>.

例外狀況

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

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

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

public:
generic <typename TAntecedentResult>
 System::Threading::Tasks::Task<TResult> ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task<TAntecedentResult> ^> ^ tasks, Func<System::Threading::Tasks::Task<TAntecedentResult> ^, TResult> ^ continuationFunction, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task<TResult> ContinueWhenAny<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>,TResult> continuationFunction, System.Threading.CancellationToken cancellationToken);
member this.ContinueWhenAny : System.Threading.Tasks.Task<'AntecedentResult>[] * Func<System.Threading.Tasks.Task<'AntecedentResult>, 'Result> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Result>

類型參數

TAntecedentResult

前項 tasks 的結果類型。The type of the result of the antecedent tasks.

參數

tasks
Task<TAntecedentResult>[]

工作的陣列,當其中一個工作完成時,會接續另一個工作。The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

tasks 陣列中的任一個工作已經完成時,要以非同步方式執行的函式委派。The function delegate to execute asynchronously when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的取消語彙基元。The cancellation token that will be assigned to the new continuation task.

傳回

新的接續工作。The new continuation task.

例外狀況

tasks陣列中的其中一個項目已經過處置。One of the elements in the tasks array has been disposed.

-或--or- 已處置建立 CancellationTokenSourcecancellationTokenThe CancellationTokenSource that created cancellationToken has already been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunction 引數為 nullThe continuationFunction argument is null.

tasks 陣列包含 null 值。The tasks array contains a null value.

-或--or- tasks 陣列是空的。The tasks array is empty.

備註

完成之後,工作會處於下列其中一種狀態: [RanToCompletion]、[Faulted] 或 [Canceled 狀態]。After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

另請參閱

適用於