WaitAll Method (Task[])
Collapse the table of content
Expand the table of content

Task::WaitAll Method (array<Task^>^)

 

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

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

public:
static void WaitAll(
	... array<Task^>^ tasks
)

Parameters

tasks
Type: array<System.Threading.Tasks::Task^>^

An array of Task instances on which to wait.

Exception Condition
ObjectDisposedException

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

ArgumentNullException

The tasks argument is null.

ArgumentException

The tasks argument contains a null element.

-or-

The tasks argument is an empty array.

AggregateException

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.

-or-

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
Silverlight
Available since 5.0
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1
Return to top
Show:
© 2016 Microsoft