WaitHandle.WaitTimeout Field

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Const WaitTimeout As Integer
public const int WaitTimeout

Remarks

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

Examples

The following example shows how to use the WaitTimeout field with the WaitAny(array<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.
Dim waitHandles() As WaitHandle = finished.ToArray()
Dim index As Integer = 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)
   worker.ReportProgress(1)

End While
// 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);
   worker.ReportProgress(1);
}

Version Information

Silverlight

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

Platforms

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