Task.WaitAll Method (Task[])
Waits for all of the provided Task objects to complete execution.
Assembly: mscorlib (in mscorlib.dll)
| 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.
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