WhenAny Method (IEnumerable(Task))
Collapse the table of content
Expand the table of content

Task.WhenAny Method (IEnumerable(Of Task))

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

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

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

'Declaration
Public Shared Function WhenAny ( _
	tasks As IEnumerable(Of Task) _
) As Task(Of Task)

Parameters

tasks
Type: System.Collections.Generic.IEnumerable(Of Task)
The tasks to wait on for completion.

Return Value

Type: System.Threading.Tasks.Task(Of Task)
A task that represents the completion of one of the supplied tasks. The return Task's Result is the task that completed.

ExceptionCondition
ArgumentNullException

The tasks argument was null.

ArgumentException

The tasks array contained a null task, or was empty.

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.

Windows Phone OS

Supported in: 8.1, 8.0

Show:
© 2017 Microsoft