System.Threading.WaitHandle.WaitAll Method

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

Syntax

public static bool WaitAll (WaitHandle[] waitHandles, int millisecondsTimeout)

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 (duplicates).
millisecondsTimeout
The number of milliseconds to wait, or Timeout.Infinite (-1) to wait indefinitely.

Returns

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

Remarks

If millisecondsTimeout 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 when all the handles are signaled or when time-out occurs. On some implementations, if more than 64 handles are passed, a NotSupportedException is thrown. If there are duplicates in the array, the call fails with a DuplicateWaitObjectException.

Note:

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

Calling this method overload is the same as calling the WaitHandle.WaitAll(WaitHandle[], int, 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