/// <summary>Waits for all the elements in the specified array to receive a signal, using an <see cref="T:System.Int32" /> value to specify the time interval and specifying whether to exit the synchronization domain before the wait.</summary> /// <returns>true when every element in <paramref name="waitHandles" /> has received a signal; otherwise, false.</returns> /// <param name="waitHandles">A WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object (duplicates). </param> /// <param name="millisecondsTimeout">The number of milliseconds to wait, or <see cref="F:System.Threading.Timeout.Infinite" /> (-1) to wait indefinitely. </param> /// <param name="exitContext">true to exit the synchronization domain for the context before the wait (if in a synchronized context), and reacquire it afterward; otherwise, false. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="waitHandles" /> parameter is null.-or- One or more of the objects in the <paramref name="waitHandles" /> array is null. -or-<paramref name="waitHandles" /> is an array with no elements and the .NET Framework version is 2.0 or later. </exception> /// <exception cref="T:System.DuplicateWaitObjectException">The <paramref name="waitHandles" /> array contains elements that are duplicates. </exception> /// <exception cref="T:System.NotSupportedException">The number of objects in <paramref name="waitHandles" /> is greater than the system permits.-or- The <see cref="T:System.STAThreadAttribute" /> attribute is applied to the thread procedure for the current thread, and <paramref name="waitHandles" /> contains more than one element. </exception> /// <exception cref="T:System.ApplicationException"> /// <paramref name="waitHandles" /> is an array with no elements and the .NET Framework version is 1.0 or 1.1. </exception> /// <exception cref="T:System.ArgumentOutOfRangeException"> /// <paramref name="millisecondsTimeout" /> is a negative number other than -1, which represents an infinite time-out. </exception> /// <exception cref="T:System.Threading.AbandonedMutexException">The wait completed because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.</exception> /// <exception cref="T:System.InvalidOperationException">The <paramref name="waitHandles" /> array contains a transparent proxy for a <see cref="T:System.Threading.WaitHandle" /> in another application domain.</exception> /// <filterpriority>1</filterpriority> public static bool WaitAll(WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext) { WaitHandle.CheckArray(waitHandles, true); if (millisecondsTimeout < -1) { throw new ArgumentOutOfRangeException("millisecondsTimeout"); } bool result; try { if (exitContext) { SynchronizationAttribute.ExitContext(); } result = WaitHandle.WaitAll_internal(waitHandles, millisecondsTimeout, false); } finally { if (exitContext) { SynchronizationAttribute.EnterContext(); } } return(result); }
public static int WaitAny(WaitHandle[] waitHandles, TimeSpan timeout, bool exitContext) { WaitHandle.CheckArray(waitHandles, false); long num = (long)timeout.TotalMilliseconds; if (num < -1L || num > 2147483647L) { throw new ArgumentOutOfRangeException("timeout"); } int result; try { if (exitContext) { SynchronizationAttribute.ExitContext(); } result = WaitHandle.WaitAny_internal(waitHandles, (int)num, exitContext); } finally { if (exitContext) { SynchronizationAttribute.EnterContext(); } } return(result); }
/// <summary>Waits for all the elements in the specified array to receive a signal.</summary> /// <returns>true when every element in <paramref name="waitHandles" /> has received a signal; otherwise the method never returns.</returns> /// <param name="waitHandles">A WaitHandle array containing the objects for which the current instance will wait. This array cannot contain multiple references to the same object. </param> /// <exception cref="T:System.ArgumentNullException">The <paramref name="waitHandles" /> parameter is null. -or- One or more of the objects in the <paramref name="waitHandles" /> array are null. -or-<paramref name="waitHandles" /> is an array with no elements and the .NET Framework version is 2.0 or later. </exception> /// <exception cref="T:System.DuplicateWaitObjectException">The <paramref name="waitHandles" /> array contains elements that are duplicates. </exception> /// <exception cref="T:System.NotSupportedException">The number of objects in <paramref name="waitHandles" /> is greater than the system permits.-or- The <see cref="T:System.STAThreadAttribute" /> attribute is applied to the thread procedure for the current thread, and <paramref name="waitHandles" /> contains more than one element. </exception> /// <exception cref="T:System.ApplicationException"> /// <paramref name="waitHandles" /> is an array with no elements and the .NET Framework version is 1.0 or 1.1. </exception> /// <exception cref="T:System.Threading.AbandonedMutexException">The wait terminated because a thread exited without releasing a mutex. This exception is not thrown on Windows 98 or Windows Millennium Edition.</exception> /// <exception cref="T:System.InvalidOperationException">The <paramref name="waitHandles" /> array contains a transparent proxy for a <see cref="T:System.Threading.WaitHandle" /> in another application domain.</exception> /// <filterpriority>1</filterpriority> public static bool WaitAll(WaitHandle[] waitHandles) { WaitHandle.CheckArray(waitHandles, true); return(WaitHandle.WaitAll_internal(waitHandles, -1, false)); }
public static int WaitAny(WaitHandle[] waitHandles) { WaitHandle.CheckArray(waitHandles, false); return(WaitHandle.WaitAny_internal(waitHandles, -1, false)); }