System.Threading.WaitHandle.WaitAll Method

Waits for all the elements in the specified array to receive a signal.

Syntax

public static bool WaitAll (WaitHandle[] waitHandles)

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.

Returns

true when every element in waitHandles has received a signal; otherwise the method never returns.

Exceptions

TypeReason
ArgumentNullException waitHandles is null or one or more elements in the waitHandles array is null.
DuplicateWaitObjectException waitHandles contains elements that are duplicates.
NotSupportedExceptionThe number of objects in waitHandles is greater than the system permits.

Remarks

System.Threading.AbandonedMutexException is new in the .NET Framework version 2.0. In previous versions, the erload:System.Threading.WaitHandle.WaitAll method returns true when a mutex is abandoned. An abandoned mutex often indicates a serious coding error. In the case of a system-wide mutex, it might indicate that an application has been terminated abruptly (for example, by using Windows Task Manager). The exception contains information useful for debugging.

The erload:System.Threading.WaitHandle.WaitAll method returns when all the handles are signaled. On some implementations, if more than 64 handles are passed, a NotSupportedException is thrown. If the array contains duplicates, 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 equivalent to calling the WaitHandle.WaitAll(WaitHandle[], int, bool) method overload and specifying -1 (or Timeout.Infinite) for millisecondsTimeout and true for exitContext.

Requirements

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