Table of Contents

Class WaitHandle

Namespace
System.Threading
Assembly
mscorlib.dll

Encapsulates operating system specific objects that wait for exclusive access to shared resources.

public abstract class WaitHandle : MarshalByRefObject
Inheritance
WaitHandle
Derived
Inherited Members
Extension Methods

Constructors

WaitHandle()

protected WaitHandle()

Fields

WaitTimeout

Indicates that a WaitAny operation timed out before any of the wait handles were signaled. This field is constant.

public const int WaitTimeout = 258

Field Value

int

Methods

WaitAll(WaitHandle[])

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

public static bool WaitAll(WaitHandle[] waitHandles)

Parameters

waitHandles WaitHandle[]

A WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object.

Returns

bool

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

WaitAll(WaitHandle[], int, bool)

Waits for all the elements in the specified array to receive a signal, using an Int32 value to specify the time interval and specifying whether to exit the synchronization domain before the wait.

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

Parameters

waitHandles WaitHandle[]

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 int

The number of milliseconds to wait, or Timeout.Infinite (-1) to wait indefinitely.

exitContext bool

true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.

Returns

bool

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

WaitAny(WaitHandle[])

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

public static int WaitAny(WaitHandle[] waitHandles)

Parameters

waitHandles WaitHandle[]

A WaitHandle array containing the objects for which the current instance will wait.

Returns

int

The array index of the object that satisfied the wait.

WaitAny(WaitHandle[], int, bool)

Waits for any of the elements in the specified array to receive a signal, using a 32-bit signed integer to specify the time interval, and specifying whether to exit the synchronization domain before the wait.

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

Parameters

waitHandles WaitHandle[]

A WaitHandle array containing the objects for which the current instance will wait.

millisecondsTimeout int

The number of milliseconds to wait, or Timeout.Infinite (-1) to wait indefinitely.

exitContext bool

true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.

Returns

int

The array index of the object that satisfied the wait, or WaitTimeout if no object satisfied the wait and a time interval equivalent to millisecondsTimeout has passed.

WaitOne()

Blocks the current thread until the current WaitHandle receives a signal.

public virtual bool WaitOne()

Returns

bool

true if the current instance receives a signal. If the current instance is never signaled, WaitOne never returns.

WaitOne(int, bool)

Blocks the current thread until the current WaitHandle receives a signal, using a 32-bit signed integer to specify the time interval and specifying whether to exit the synchronization domain before the wait.

public virtual bool WaitOne(int millisecondsTimeout, bool exitContext)

Parameters

millisecondsTimeout int

The number of milliseconds to wait, or Timeout.Infinite (-1) to wait indefinitely.

exitContext bool

true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false.

Returns

bool

true if the current instance receives a signal; otherwise, false.