WaitHandle.WaitTimeout Field

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

Namespace:  System.Threading
Assembly:  mscorlib (in mscorlib.dll)

public const int WaitTimeout

This field is one of the possible return values of WaitAny.

The following example shows how to use the WaitTimeout field with the WaitAny(WaitHandle[], Int32) method overload to report progress while waiting for multiple threads to finish. Each time the WaitAny method times out, the thread that was waiting reports progress to the user interface thread.

This code is part of a larger example provided for the WaitHandle class.

// Wait for ANY subtask to complete, and show progress.

// Create an array of ManualResetEvent wait handles. Each subtask will
// signal its ManualResetEvent when it is finished.
WaitHandle[] waitHandles = finished.ToArray();
int index = WaitHandle.WaitTimeout;

while (index == WaitHandle.WaitTimeout)
   // Wait for any WaitHandle to be signaled. Use a timeout of 250 milliseconds 
   // to send progress reports. If a timeout occurs, WaitTimeout is returned;
   // if a WaitHandle signals, the array index of the WaitHandle is returned.
   index = WaitHandle.WaitAny(waitHandles, 250);


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

Community Additions