TaskFactory.ContinueWhenAny 方法

定義

建立會在提供的任何一項工作完成時啟動的 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(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>)

建立會在提供的任何一項工作完成時啟動的 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<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,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>(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>>, TaskContinuationOptions)

建立會在提供的任何一項工作完成時啟動的 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<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>, TaskContinuationOptions)

建立會在提供的任何一項工作完成時啟動的 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(Task[], Action<Task>, TaskContinuationOptions)

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

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

參數

tasks
Task[]

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

continuationAction
Action<Task>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

continuationOptions
TaskContinuationOptions

TaskContinuationOptions 值,控制建立之接續 Task 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task.

傳回

新的接續 TaskThe new continuation Task.

例外狀況

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

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationActionnullcontinuationAction is null.

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

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

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

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

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.

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

參數

tasks
Task[]

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

continuationAction
Action<Task>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

continuationOptions
TaskContinuationOptions

TaskContinuationOptions 值,控制建立之接續 Task 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task.

scheduler
TaskScheduler

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

傳回

新的接續 TaskThe new continuation Task.

例外狀況

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationActionnullcontinuationAction is null.

-或--or- schedulernullscheduler is null.

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

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

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

ContinueWhenAny(Task[], Action<Task>)

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

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

參數

tasks
Task[]

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

continuationAction
Action<Task>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

傳回

新的接續 TaskThe new continuation Task.

例外狀況

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

tasks 陣列為 nullThe tasks array is null.

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

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

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

範例

下列範例顯示如何使用 ContinueWhenAnyContinueWhenAllThe following example shows how to use ContinueWhenAny and ContinueWhenAll:

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

class ContinueWhenMultiDemo
{
    // Demonstrated features:
    // 		Task.Factory
    //		TaskFactory.ContinueWhenAll()
    //		TaskFactory.ContinueWhenAny()
    //		Task.Wait()
    // Expected results:
    // 		Three tasks are created in parallel. 
    //		Each task for a different period of time prints a number and returns it.
    //      A ContinueWhenAny() task indicates the first of the three tasks to complete.
    //      A ContinueWhenAll() task sums up the results of the three tasks and prints out the total.
    // Documentation:
    //		http://msdn.microsoft.com/library/system.threading.tasks.taskfactory_members(VS.100).aspx
    static void Main()
    {
        // Schedule a list of tasks that return integer
        Task<int>[] tasks = new Task<int>[]
            {
                Task<int>.Factory.StartNew(() => 
                    {
                        Thread.Sleep(500);
                        Console.WriteLine("Task={0}, Thread={1}, x=5", Task.CurrentId, Thread.CurrentThread.ManagedThreadId);
                        return 5;
                    }),

                Task<int>.Factory.StartNew(() => 
                    {
                        Thread.Sleep(10);
                        Console.WriteLine("Task={0}, Thread={1}, x=3", Task.CurrentId, Thread.CurrentThread.ManagedThreadId);
                        return 3;
                    }),

                Task<int>.Factory.StartNew(() => 
                    {
                        Thread.Sleep(200);
                        Console.WriteLine("Task={0}, Thread={1}, x=2", Task.CurrentId, Thread.CurrentThread.ManagedThreadId);
                        return 2;
                    })
            };

        // Schedule a continuation to indicate the result of the first task to complete
        Task.Factory.ContinueWhenAny(tasks, winner =>
        {
            // You would expect winning result = 3 on multi-core systems, because you expect
            // tasks[1] to finish first.
            Console.WriteLine("Task={0}, Thread={1} (ContinueWhenAny): Winning result = {2}", Task.CurrentId, Thread.CurrentThread.ManagedThreadId, winner.Result);
        });

        // Schedule a continuation that sums up the results of all tasks, then wait on it.
        // The list of antecendent tasks is passed as an argument by the runtime.
        Task.Factory.ContinueWhenAll(tasks,
            (antecendents) =>
            {
                int sum = 0;
                foreach (Task<int> task in antecendents)
                {
                    sum += task.Result;
                }

                Console.WriteLine("Task={0}, Thread={1}, (ContinueWhenAll): Total={2} (expected 10)", Task.CurrentId, Thread.CurrentThread.ManagedThreadId, sum);
            })
            .Wait();
    }
}
Imports System.Threading
Imports System.Threading.Tasks

Module ContinuationWhenMulti
    ' Demonstrated features:
    '   Task.Factory
    '   TaskFactory.ContinueWhenAll()
    '   TaskFactory.ContinueWhenAny()
    '   Task.Wait()
    ' Expected results:
    '   Three tasks are created in parallel. 
    '   Each task for a different period of time prints a number and returns it.
    '   A ContinueWhenAny() task indicates the first of the three tasks to complete.
    '   A ContinueWhenAll() task sums up the results of the three tasks and prints out the total.
    ' Documentation:
    '   http://msdn.microsoft.com/library/system.threading.tasks.taskfactory_members(VS.100).aspx
    Sub Main()
        ' Schedule a list of tasks that return integer
        Dim tasks As Task(Of Integer)() = New Task(Of Integer)() {
            Task(Of Integer).Factory.StartNew(Function()
                                                  Thread.Sleep(500)
                                                  Console.WriteLine("Task={0}, Thread={1}, x=5", Task.CurrentId, Thread.CurrentThread.ManagedThreadId)
                                                  Return 5
                                              End Function),
            Task(Of Integer).Factory.StartNew(Function()
                                                  Thread.Sleep(10)
                                                  Console.WriteLine("Task={0}, Thread={1}, x=3", Task.CurrentId, Thread.CurrentThread.ManagedThreadId)
                                                  Return 3
                                              End Function),
            Task(Of Integer).Factory.StartNew(Function()
                                                  Thread.Sleep(200)
                                                  Console.WriteLine("Task={0}, Thread={1}, x=2", Task.CurrentId, Thread.CurrentThread.ManagedThreadId)
                                                  Return 2
                                              End Function)}


        ' Schedule a continuation to indicate the result of the first task to complete
        Task.Factory.ContinueWhenAny(tasks, Sub(winner)
                                                ' You would expect winning result = 3 on multi-core systems, because you expect
                                                ' tasks[1] to finish first.
                                                Console.WriteLine("Task={0}, Thread={1} (ContinueWhenAny): Winning result = {2}", Task.CurrentId, Thread.CurrentThread.ManagedThreadId, winner.Result)
                                            End Sub)


        ' Schedule a continuation that sums up the results of all tasks, then wait on it.
        ' The list of antecendent tasks is passed as an argument by the runtime.
        Task.Factory.ContinueWhenAll(tasks, Sub(antecendents)
                                                Dim sum As Integer = 0
                                                For Each task__1 As Task(Of Integer) In antecendents
                                                    sum += task__1.Result
                                                Next
                                                Console.WriteLine("Task={0}, Thread={1}, (ContinueWhenAll): Total={2} (expected 10)", Task.CurrentId, Thread.CurrentThread.ManagedThreadId, sum)
                                            End Sub).Wait()
    End Sub
End Module

另請參閱

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

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

public:
 System::Threading::Tasks::Task ^ ContinueWhenAny(cli::array <System::Threading::Tasks::Task ^> ^ tasks, Action<System::Threading::Tasks::Task ^> ^ continuationAction, System::Threading::CancellationToken cancellationToken);
public System.Threading.Tasks.Task ContinueWhenAny (System.Threading.Tasks.Task[] tasks, Action<System.Threading.Tasks.Task> continuationAction, System.Threading.CancellationToken cancellationToken);
member this.ContinueWhenAny : System.Threading.Tasks.Task[] * Action<System.Threading.Tasks.Task> * System.Threading.CancellationToken -> System.Threading.Tasks.Task

參數

tasks
Task[]

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

continuationAction
Action<Task>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

傳回

新的接續 TaskThe new continuation Task.

例外狀況

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

-或--or- cancellationToken 已經處置。cancellationToken has already been disposed.

tasks 陣列為 nullThe tasks array is null.

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

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

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

另請參閱

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.

public:
generic <typename TAntecedentResult, typename TResult>
 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,TResult> (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, TResult) (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.

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<TResult>.

參數

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

TaskContinuationOptions 值,控制建立之接續 Task<TResult> 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task<TResult>.

傳回

新的接續 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- continuationFunctionnullcontinuationFunction is null.

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

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

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

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

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.

public:
generic <typename TAntecedentResult, typename TResult>
 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,TResult> (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, TResult) (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.

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<TResult>.

參數

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- continuationFunctionnullcontinuationFunction is null.

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

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

另請參閱

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.

public:
generic <typename TAntecedentResult, typename TResult>
 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,TResult> (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.

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<TResult>.

參數

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

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

傳回

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

例外狀況

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

-或--or- 提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunctionnullcontinuationFunction is null.

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

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

另請參閱

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.

public:
generic <typename TAntecedentResult, typename TResult>
 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,TResult> (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.

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<TResult>.

參數

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

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

continuationOptions
TaskContinuationOptions

TaskContinuationOptions 值,控制建立之接續 Task<TResult> 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task<TResult>.

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- continuationFunctionnullcontinuationFunction is null.

-或--or- schedulernullscheduler is null.

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

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

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

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.

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

類型參數

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.

continuationAction
Action<Task<TAntecedentResult>>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

傳回

新的接續 TaskThe new continuation Task.

例外狀況

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

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationActionnullcontinuationAction is null.

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

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

另請參閱

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.

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

類型參數

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.

continuationAction
Action<Task<TAntecedentResult>>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

傳回

新的接續 TaskThe new continuation Task.

例外狀況

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

-或--or- 提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationActionnullcontinuationAction is null.

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

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

另請參閱

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.

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

類型參數

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.

continuationAction
Action<Task<TAntecedentResult>>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

continuationOptions
TaskContinuationOptions

TaskContinuationOptions 值,控制建立之接續 Task 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task.

傳回

新的接續 TaskThe new continuation Task.

例外狀況

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

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationActionnullcontinuationAction is null.

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

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

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

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

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.

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

類型參數

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.

continuationAction
Action<Task<TAntecedentResult>>

tasks 陣列中的任一個工作已經完成時,要執行的動作委派。The action delegate to execute when one task in the tasks array completes.

cancellationToken
CancellationToken

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

continuationOptions
TaskContinuationOptions

TaskContinuationOptions 值,控制建立之接續 Task 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task.

scheduler
TaskScheduler

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

傳回

新的接續 TaskThe new continuation Task.

例外狀況

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationActionnullcontinuationAction is null.

-或--or- paramref name="scheduler" /> 是 nullparamref name="scheduler" /> is null.

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

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

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

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.

public:
generic <typename TResult>
 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<TResult> (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(Of TResult) (tasks As Task(), continuationFunction As Func(Of Task, TResult)) As Task(Of TResult)

類型參數

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<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.

傳回

新的接續 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- continuationFunctionnullcontinuationFunction is null.

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

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

另請參閱

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.

public:
generic <typename TResult>
 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<TResult> (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>

類型參數

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<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.

cancellationToken
CancellationToken

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

傳回

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

例外狀況

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

-或--or- 提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

tasks 陣列為 nullThe tasks array is null.

-或--or- continuationFunctionnullcontinuationFunction is null.

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

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

另請參閱

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.

public:
generic <typename TResult>
 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<TResult> (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(Of TResult) (tasks As Task(), continuationFunction As Func(Of Task, TResult), continuationOptions As TaskContinuationOptions) As Task(Of TResult)

類型參數

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<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

TaskContinuationOptions 值,控制建立之接續 Task<TResult> 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task<TResult>.

傳回

新的接續 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- continuationFunctionnullcontinuationFunction is null.

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

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

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

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

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.

public:
generic <typename TResult>
 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<TResult> (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>

類型參數

TResult

continuationFunction 委派傳回,且與建立之 Task<TResult> 相關聯的結果的類型。The type of the result that is returned by the continuationFunction delegate and associated with the created Task<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.

cancellationToken
CancellationToken

要指派給新接續工作的 CancellationTokenThe CancellationToken that will be assigned to the new continuation task.

continuationOptions
TaskContinuationOptions

TaskContinuationOptions 值,控制建立之接續 Task<TResult> 的行為。The TaskContinuationOptions value that controls the behavior of the created continuation Task<TResult>.

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- continuationFunctionnullcontinuationFunction is null.

-或--or- schedulernullscheduler is null.

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

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

continuationOptions 指定無效的 TaskContinuationOptions 值。continuationOptions specifies an invalid TaskContinuationOptions value.

提供的 CancellationToken 已經過處置。The provided CancellationToken has already been disposed.

備註

NotOn* 和 OnlyOn* TaskContinuationOptions,其會限制將執行接續的 TaskStatus 狀態,與 ContinueWhenAny不合法。The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAny.

另請參閱

適用於