TaskFactory.ContinueWhenAll Method

Definition

Creates a continuation task that starts when a set of specified tasks has completed.

Overloads

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[]>, TaskContinuationOptions)

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<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,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>)

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<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>[]>)

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>, TaskContinuationOptions)

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(Task[], Action<Task[]>)

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll (System.Threading.Tasks.Task[] tasks, Action<System.Threading.Tasks.Task[]> continuationAction);

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationAction
Action<Task[]>

The action delegate to execute when all tasks in the tasks array have completed.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationAction argument is null.

The tasks array is empty or contains a null value.

Examples

The following example launches separate tasks that use a regular expression to count the number of words in a set of text files. The ContinueWhenAll method is used to launch a task that displays the total word count when all the antecedent tasks have completed.

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

public class Example
{
   public static void Main()
   {
      string[] filenames = { "chapter1.txt", "chapter2.txt", 
                             "chapter3.txt", "chapter4.txt",
                             "chapter5.txt" };
      string pattern = @"\b\w+\b";
      var tasks = new List<Task>();  
      int totalWords = 0;
        
      // Determine the number of words in each file.
      foreach (var filename in filenames) 
         tasks.Add( Task.Factory.StartNew( fn => { if (!File.Exists(fn.ToString()))
                                                      throw new FileNotFoundException("{0} does not exist.", filename);

                                                   StreamReader sr = new StreamReader(fn.ToString());
                                                   String content = sr.ReadToEnd();
                                                   sr.Close();
                                                   int words = Regex.Matches(content, pattern).Count;
                                                   Interlocked.Add(ref totalWords, words); 
                                                   Console.WriteLine("{0,-25} {1,6:N0} words", fn, words); }, 
                                           filename));

      var finalTask = Task.Factory.ContinueWhenAll(tasks.ToArray(), wordCountTasks => {
                                                    int nSuccessfulTasks = 0;
                                                    int nFailed = 0;
                                                    int nFileNotFound = 0;
                                                    foreach (var t in wordCountTasks) {
                                                       if (t.Status == TaskStatus.RanToCompletion) 
                                                          nSuccessfulTasks++;
                                                       
                                                       if (t.Status == TaskStatus.Faulted) {
                                                          nFailed++;  
                                                          t.Exception.Handle( (e) => { 
                                                             if (e is FileNotFoundException)
                                                                nFileNotFound++;
                                                             return true;   
                                                          });
                                                       } 
                                                    }   
                                                    Console.WriteLine("\n{0,-25} {1,6} total words\n", 
                                                                      String.Format("{0} files", nSuccessfulTasks), 
                                                                      totalWords); 
                                                    if (nFailed > 0) {
                                                       Console.WriteLine("{0} tasks failed for the following reasons:", nFailed);
                                                       Console.WriteLine("   File not found:    {0}", nFileNotFound);
                                                       if (nFailed != nFileNotFound)
                                                          Console.WriteLine("   Other:          {0}", nFailed - nFileNotFound);
                                                    } 
                                                    });  
      finalTask.Wait();                                                                  
   }
}
// The example displays output like the following:
//       chapter2.txt               1,585 words
//       chapter1.txt               4,012 words
//       chapter5.txt               4,660 words
//       chapter3.txt               7,481 words
//       
//       4 files                    17738 total words
//       
//       1 tasks failed for the following reasons:
//          File not found:    1

The call to the continuation task's Task.Wait method does not allow it to handle exceptions thrown by the antecedent tasks, so the example examines the Task.Status property of each antecedent task to determine whether the task succeeded.

Remarks

The ContinueWhenAll method executes the continuationAction delegate when all tasks in the tasks array have completed, regardless of their completion status.

Exceptions thrown by tasks in the tasks array are not available to the continuation task through structured exception handling. You can determine which exceptions were thrown by examining the Task.Exception property of each task in the tasks array. To use structured exception handling to handle exceptions thrown by tasks in the tasks array, call the Task.WaitAll(Task[]) method.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll (System.Threading.Tasks.Task[] tasks, Action<System.Threading.Tasks.Task[]> continuationAction, System.Threading.CancellationToken cancellationToken);

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationAction
Action<Task[]>

The action delegate to execute when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

The tasks array is null.

-or-

The continuationAction argument is null.

The tasks array is empty or contains a null value.

Examples

The following example creates a cancellation token, which it passes to separate tasks that use a regular expression to count the number of words in a set of text files. The cancellation token is set if a file cannot be found. The ContinueWhenAll(Task[], Action{Task[]}, CancellationToken) method is used to launch a task that displays the total word count when all the antecedent tasks have completed. If the cancellation token is set, which indicates that one or more tasks have been cancelled, it handles the AggregateException exception and displays an error message.

using System;
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Text.RegularExpressions;

public class Example
{
   public static void Main()
   {
      string[] filenames = { "chapter1.txt", "chapter2.txt", 
                             "chapter3.txt", "chapter4.txt",
                             "chapter5.txt" };
      string pattern = @"\b\w+\b";
      var tasks = new List<Task>();  
      CancellationTokenSource source = new CancellationTokenSource();
      CancellationToken token = source.Token;
      int totalWords = 0;
        
      // Determine the number of words in each file.
      foreach (var filename in filenames)
         tasks.Add( Task.Factory.StartNew( fn => { token.ThrowIfCancellationRequested(); 

                                                   if (!File.Exists(fn.ToString())) {
                                                      source.Cancel();
                                                      token.ThrowIfCancellationRequested();
                                                   }
                                                   
                                                   StreamReader sr = new StreamReader(fn.ToString());
                                                   String content = sr.ReadToEnd();
                                                   sr.Close();
                                                   int words = Regex.Matches(content, pattern).Count;
                                                   Interlocked.Add(ref totalWords, words); 
                                                   Console.WriteLine("{0,-25} {1,6:N0} words", fn, words); }, 
                                           filename, token));

      var finalTask = Task.Factory.ContinueWhenAll(tasks.ToArray(), wordCountTasks => {
                                                    if (!token.IsCancellationRequested) 
                                                       Console.WriteLine("\n{0,-25} {1,6} total words\n", 
                                                                         String.Format("{0} files", wordCountTasks.Length), 
                                                                         totalWords); 
                                                   }, token); 
      try {                                                   
         finalTask.Wait();
      }
      catch (AggregateException ae) {
         foreach (Exception inner in ae.InnerExceptions)
            if (inner is TaskCanceledException)
               Console.WriteLine("\nFailure to determine total word count: a task was cancelled.");
            else
               Console.WriteLine("\nFailure caused by {0}", inner.GetType().Name);      
      }
      finally {
         source.Dispose();
      }
   }
}
// The example displays output like the following:
//       chapter2.txt               1,585 words
//       chapter1.txt               4,012 words
//       
//       Failure to determine total word count: a task was cancelled.

Remarks

This method executes the continuationAction delegate when all tasks in the tasks array have completed, regardless of their completion status.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll (System.Threading.Tasks.Task[] tasks, Action<System.Threading.Tasks.Task[]> continuationAction, System.Threading.Tasks.TaskContinuationOptions continuationOptions);

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationAction
Action<Task[]>

The action delegate to execute when all tasks in the tasks array have completed.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationAction argument is null.

The continuationOptions argument specifies an invalid value.

The tasks array is empty or contains a null value.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll (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);

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationAction
Action<Task[]>

The action delegate to execute when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task.

scheduler
TaskScheduler

The object that is used to schedule the new continuation task.

Returns

The new continuation task.

Exceptions

The tasks array is null.

-or-

The continuationAction argument is null.

-or-

The scheduler argument is null.

The tasks array is empty or contains a null value.

continuationOptions specifies an invalid TaskContinuationOptions value.

The provided CancellationToken has already been disposed.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<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);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationFunction
Func<Task<TAntecedentResult>[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

scheduler
TaskScheduler

The object that is used to schedule the new continuation task.

Returns

The new continuation task.

Exceptions

The tasks array is null.

-or-

The continuationFunction argument is null.

-or-

The scheduler argument is null.

The tasks array is empty or contains a null value.

The continuationOptions argument specifies an invalid value.

An element in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<TAntecedentResult,TResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>[],TResult> continuationFunction, System.Threading.Tasks.TaskContinuationOptions continuationOptions);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationFunction
Func<Task<TAntecedentResult>[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The continuationOptions argument specifies an invalid value.

The tasks array is empty or contains a null value.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<TAntecedentResult,TResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>[],TResult> continuationFunction, System.Threading.CancellationToken cancellationToken);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationFunction
Func<Task<TAntecedentResult>[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The tasks array is empty or contains a null value.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<TAntecedentResult,TResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Func<System.Threading.Tasks.Task<TAntecedentResult>[],TResult> continuationFunction);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationFunction
Func<Task<TAntecedentResult>[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The tasks array is empty or contains a null value.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll<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);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationAction
Action<Task<TAntecedentResult>[]>

The action delegate to execute when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

scheduler
TaskScheduler

The object that is used to schedule the new continuation task.

Returns

The new continuation task.

Exceptions

The tasks array is null.

-or-

The continuationAction argument is null.

-or-

The scheduler argument is null.

The tasks array is empty or contains a null value.

continuationOptions specifies an invalid TaskContinuationOptions value.

The provided CancellationToken has already been disposed.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Action<System.Threading.Tasks.Task<TAntecedentResult>[]> continuationAction, System.Threading.Tasks.TaskContinuationOptions continuationOptions);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationAction
Action<Task<TAntecedentResult>[]>

The action delegate to execute when all tasks in the tasks array have completed.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationAction argument is null.

The continuationOptions argument specifies an invalid value.

The tasks array is empty or contains a null value.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Action<System.Threading.Tasks.Task<TAntecedentResult>[]> continuationAction, System.Threading.CancellationToken cancellationToken);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationAction
Action<Task<TAntecedentResult>[]>

The action delegate to execute when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

The tasks array is null.

-or-

The continuationAction argument is null.

The tasks array is empty or contains a null value.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task ContinueWhenAll<TAntecedentResult> (System.Threading.Tasks.Task<TAntecedentResult>[] tasks, Action<System.Threading.Tasks.Task<TAntecedentResult>[]> continuationAction);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue.

continuationAction
Action<Task<TAntecedentResult>[]>

The action delegate to execute when all tasks in the tasks array have completed.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationAction argument is null.

The tasks array is empty or contains a null value.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<TResult> (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task[],TResult> continuationFunction);

Type Parameters

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationFunction
Func<Task[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The tasks array is empty or contains a null value.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<TResult> (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task[],TResult> continuationFunction, System.Threading.CancellationToken cancellationToken);

Type Parameters

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationFunction
Func<Task[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The tasks array is empty or contains a null value.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<TResult> (System.Threading.Tasks.Task[] tasks, Func<System.Threading.Tasks.Task[],TResult> continuationFunction, System.Threading.Tasks.TaskContinuationOptions continuationOptions);

Type Parameters

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationFunction
Func<Task[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

Returns

The new continuation task.

Exceptions

An element in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The continuationOptions argument specifies an invalid value.

The tasks array is empty or contains a null value.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0

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

Source:
TaskFactory.cs
Source:
TaskFactory.cs
Source:
TaskFactory.cs

Creates a continuation task that starts when a set of specified tasks has completed.

public System.Threading.Tasks.Task<TResult> ContinueWhenAll<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);

Type Parameters

TResult

The type of the result that is returned by the continuationFunction delegate and associated with the created task.

Parameters

tasks
Task[]

The array of tasks from which to continue.

continuationFunction
Func<Task[],TResult>

The function delegate to execute asynchronously when all tasks in the tasks array have completed.

cancellationToken
CancellationToken

The cancellation token to assign to the new continuation task.

continuationOptions
TaskContinuationOptions

A bitwise combination of the enumeration values that control the behavior of the new continuation task. The NotOn* and OnlyOn* members are not supported.

scheduler
TaskScheduler

The object that is used to schedule the new continuation task.

Returns

The new continuation task.

Exceptions

The tasks array is null.

-or-

The continuationFunction argument is null.

-or-

The scheduler argument is null.

The tasks array is empty or contains a null value.

continuationOptions specifies an invalid TaskContinuationOptions value.

The provided CancellationToken has already been disposed.

Remarks

The NotOn* and OnlyOn* TaskContinuationOptions, which constrain for which TaskStatus states a continuation will be executed, are illegal with ContinueWhenAll.

See also

Applies to

.NET 9 및 기타 버전
제품 버전
.NET Core 1.0, Core 1.1, Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9
.NET Framework 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1
.NET Standard 1.0, 1.1, 1.2, 1.3, 1.4, 1.6, 2.0, 2.1
UWP 10.0