System.Threading.Tasks.Task.WhenAny Method

Creates a task that will complete when any of the supplied tasks have completed.

Syntax

public static Task<Task> WhenAny (IEnumerable<Task> tasks)

Parameters

tasks
The tasks to wait on for completion.

Returns

A task that represents the completion of one of the supplied tasks. The return task's Result is the task that completed.

Remarks

The returned task will complete when any of the supplied tasks has completed. The returned task will always end in the RanToCompletion state with its Result set to the first task to complete. This is true even if the first task to complete ended in the Canceled or Faulted state.

Requirements

Namespace: System.Threading.Tasks
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0