示例#1
0
 /// <summary>Signals one wait handle and waits on another, specifying a time-out interval as a 32-bit signed integer and specifying whether to exit the synchronization domain for the context before entering the wait.</summary>
 /// <returns>true if both the signal and the wait completed successfully, or false if the signal completed but the wait timed out.</returns>
 /// <param name="toSignal">The wait handle to signal.</param>
 /// <param name="toWaitOn">The wait handle to wait on.</param>
 /// <param name="millisecondsTimeout">An integer that represents the interval to wait. If the value is <see cref="F:System.Threading.Timeout.Infinite" />, that is, -1, the wait is infinite.</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">
 ///   <paramref name="toSignal" /> is null.-or-<paramref name="toWaitOn" /> is null. </exception>
 /// <exception cref="T:System.NotSupportedException">The method is called on a thread that has <see cref="T:System.STAThreadAttribute" />. </exception>
 /// <exception cref="T:System.PlatformNotSupportedException">This method is not supported on Windows 98 or Windows Millennium Edition. </exception>
 /// <exception cref="T:System.InvalidOperationException">
 ///   <paramref name="toSignal" /> is a semaphore, and it already has a full count. </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 <see cref="T:System.Threading.WaitHandle" /> cannot be signaled because it would exceed its maximum count.</exception>
 /// <filterpriority>1</filterpriority>
 public static bool SignalAndWait(WaitHandle toSignal, WaitHandle toWaitOn, int millisecondsTimeout, bool exitContext)
 {
     if (toSignal == null)
     {
         throw new ArgumentNullException("toSignal");
     }
     if (toWaitOn == null)
     {
         throw new ArgumentNullException("toWaitOn");
     }
     if (millisecondsTimeout < -1)
     {
         throw new ArgumentOutOfRangeException("millisecondsTimeout");
     }
     return(WaitHandle.SignalAndWait_Internal(toSignal.Handle, toWaitOn.Handle, millisecondsTimeout, exitContext));
 }