Task::WaitAny Method (array<Task^>^)
Waits for any of the provided Task objects to complete execution.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- tasks
-
Type:
array<System.Threading.Tasks::Task^>^
An array of Task instances on which to wait.
| Exception | Condition |
|---|---|
| ObjectDisposedException | The Task has been disposed. |
| ArgumentNullException | The tasks argument is null. |
| ArgumentException | The tasks argument contains a null element. |
The following example launches five tasks, each of which sleeps for a minimum of 50 milliseconds or a maximum of 1,050 milliseconds. The WaitAny method then waits for any of the tasks to complete. The example displays the task ID of the task that ended the wait, as well as the current status of all the tasks.
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