Task.WaitAll Method (Task[])


Waits for all of the provided Task objects to complete execution.

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

static member WaitAll : 
        [<ParamArrayAttribute>] tasks:Task[] -> unit


Type: System.Threading.Tasks.Task[]

An array of Task instances on which to wait.

Exception Condition

One or more of the Task objects in tasks has been disposed.


The tasks argument is null.


The tasks argument contains a null element.


The tasks argument is an empty array.


At least one of the Task instances was canceled. If a task was canceled, the AggregateException exception contains an OperationCanceledException exception in its AggregateException.InnerExceptions collection.


An exception was thrown during the execution of at least one of the Task instances.

The following example starts 10 tasks, each of which is passed an index as a state object. Tasks with an index from two to five throw exceptions. The call to the WaitAll method wraps all exceptions in an AggregateException object and propagates it to the calling thread.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Available since 5.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top