System.Threading.WaitHandle.WaitAll Method

Waits for all the elements in the specified array to receive a signal, using a TimeSpan value to specify the time interval.

Syntax

public static bool WaitAll (WaitHandle[] waitHandles, TimeSpan timeout)

Parameters

waitHandles
A WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object.
timeout
A TimeSpan that represents the number of milliseconds to wait, or a TimeSpan that represents -1 milliseconds, to wait indefinitely.

Returns

true when every element in waitHandles has received a signal; otherwise, false.

Remarks

If timeout is zero, the method does not block. It tests the state of the wait handles and returns immediately.

The erload:System.Threading.WaitHandle.WaitAll method returns when the wait terminates, which means either all the handles are signaled or a time-out occurs. On some implementations, if more than 64 handles are passed, a NotSupportedException is thrown. If the array contains duplicates, the call will fail.

Note:

The erload:System.Threading.WaitHandle.WaitAll method is not supported on threads that have STAThreadAttribute.

The maximum value for timeout is int.MaxValue.

Calling this method overload is the same as calling the WaitHandle.WaitAll(WaitHandle[], TimeSpan, bool) overload and specifying false for exitContext.

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 2.0.0.0, 4.0.0.0