TaskFactory<TResult>.ContinueWhenAny Method

Definition

Creates a continuation task that will be started upon the completion of any task in the provided set.

Overloads

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)

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

C#
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);

Parameters

tasks
Task[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

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. The NotOn* and OnlyOn* values are not valid.

scheduler
TaskScheduler

The task scheduler that is used to schedule the created 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 contains a null value.

-or-

The tasks array is empty.

The continuationOptions argument specifies an invalid TaskContinuationOptions value.

One of the elements in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

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

Parameters

tasks
Task[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

The function delegate to execute asynchronously when one task in the tasks array completes.

Returns

The new continuation task.

Exceptions

One of the elements in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The tasks array contains a null value or is empty.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

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

Parameters

tasks
Task[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

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.

Returns

The new continuation task.

Exceptions

One of the elements 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 contains a null value.

-or-

The tasks array is empty.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

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

Parameters

tasks
Task[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task,TResult>

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. The NotOn* and OnlyOn* values are not valid.

Returns

The new continuation task.

Exceptions

One of the elements in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The continuationOptions argument specifies an invalid enumeration value.

The tasks array contains a null value.

-or-

The tasks array is empty.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

C#
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);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

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. The NotOn* and OnlyOn* values are not valid.

scheduler
TaskScheduler

The TaskScheduler that is used to schedule the created continuation Task<TResult>.

Returns

The new continuation Task<TResult>.

Exceptions

The tasks array is null.

-or-

The continuationFunction argument is null.

-or-

The scheduler argument is null.

The tasks array contains a null value.

-or-

The tasks array is empty.

The continuationOptions argument specifies an invalid TaskContinuationOptions value.

One of the elements in the tasks array has been disposed.

-or-

The CancellationTokenSource that created cancellationToken has already been disposed.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

C#
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);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

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. The NotOn* and OnlyOn* values are not valid.

Returns

The new continuation Task<TResult>.

Exceptions

One of the elements in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The continuationOptions argument specifies an invalid enumeration value.

The tasks array contains a null value.

-or-

The tasks array is empty.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

C#
public System.Threading.Tasks.Task<TResult> ContinueWhenAny<TAntecedentResult>(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.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

The function delegate to execute asynchronously when one task in the tasks array completes.

Returns

The new continuation Task<TResult>.

Exceptions

One of the elements in the tasks array has been disposed.

The tasks array is null.

-or-

The continuationFunction argument is null.

The tasks array contains a null value.

-or-

The tasks array is empty.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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

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

Source:
FutureFactory.cs
Source:
FutureFactory.cs
Source:
FutureFactory.cs

Creates a continuation task that will be started upon the completion of any task in the provided set.

C#
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);

Type Parameters

TAntecedentResult

The type of the result of the antecedent tasks.

Parameters

tasks
Task<TAntecedentResult>[]

The array of tasks from which to continue when one task completes.

continuationFunction
Func<Task<TAntecedentResult>,TResult>

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.

Returns

The new continuation task.

Exceptions

One of the elements 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 contains a null value.

-or-

The tasks array is empty.

Remarks

After completion, a task is in one of these states: RanToCompletion, Faulted, or Canceled states.

See also

Applies to

.NET 10 and other versions
Product Versions
.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, 10
.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