本文由机器翻译。若要查看英语原文,请勾选“英语”复选框。 也可将鼠标指针移到文本上,在弹出窗口中显示英语原文。
翻译
英语

WaitHandle.WaitAll 方法 (WaitHandle[], Int32)

 

等待指定数组中的所有元素接收信号,同时使用 Int32 值指定时间间隔。

命名空间:   System.Threading
程序集:  mscorlib(mscorlib.dll 中)

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

参数

waitHandles

一个 WaitHandle 数组,包含当前实例将等待的对象。此数组不能包含对同一对象的多个引用(重复的元素)。

millisecondsTimeout

等待的毫秒数,或为 Timeout.Infinite (-1),表示无限期等待。

返回值

Type: System.Boolean

如果 waitHandles 中的每个元素都已收到信号,则为 true;否则为 false

Exception Condition
ArgumentNullException

The waitHandles parameter is null.

-or-

One or more of the objects in the waitHandles array is null.

-or-

waitHandles is an array with no elements.

DuplicateWaitObjectException
System_CAPS_note注意

In the .NET for Windows Store apps or the , catch the base class exception, ArgumentException, instead.

The waitHandles array contains elements that are duplicates.

NotSupportedException

The number of objects in waitHandles is greater than the system permits.

-or-

The STAThreadAttribute attribute is applied to the thread procedure for the current thread, and waitHandles contains more than one element.

ArgumentOutOfRangeException

millisecondsTimeout is a negative number other than -1, which represents an infinite time-out.

AbandonedMutexException

The wait completed because a thread exited without releasing a mutex.This exception is not thrown on Windows 98 or Windows Millennium Edition.

InvalidOperationException

The waitHandles array contains a transparent proxy for a WaitHandle in another application domain.

If millisecondsTimeout is zero, the method does not block.It tests the state of the wait handles and returns immediately.

The 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.

System_CAPS_note注意

The WaitAll method is not supported on threads that have STAThreadAttribute.

Calling this method overload is the same as calling the WaitAll(WaitHandle[], Int32, Boolean) overload and specifying false for exitContext.

Universal Windows Platform
4.5 后可用
.NET Framework
2.0 后可用
Portable Class Library
受以下版本支持:portable .NET platforms
Silverlight
2.0 后可用
Windows Phone Silverlight
7.0 后可用
Windows Phone
8.1 后可用
返回页首
显示: