Exemple #1
0
        public static bool WaitOne(Original::WaitHandle h, int millisecondsTimeout, bool exitContext)
        {
            if (h == null)
            {
                throw new NullReferenceException();
            }
            var ah = new Original::WaitHandle[] { h };

            return(WaitHandleHelper.WaitGeneral(ah, millisecondsTimeout, exitContext, "WaitOne") != Original::WaitHandle.WaitTimeout);
        }
Exemple #2
0
 // SignalObjectAndWait(h1,h2, x, y) is equivalent to
 //     r = SignalObjectAndWait(h1, h2, 0, y);
 //     if(r == WAIT_TIMEOUT && x == INFINITE)
 //         WaitForSingleObject(h2, x, y);
 //
 public static bool SignalAndWait(
     Original::WaitHandle toSignal,
     Original::WaitHandle toWaitOn,
     int millisecondsTimeout, bool exitContext)
 {
     return(Helper.SimpleWrap <bool>(
                delegate(ClrSyncManager manager)
     {
         if (toSignal == null)
         {
             throw new NullReferenceException();
         }
         if (toWaitOn == null)
         {
             throw new ArgumentNullException();
         }
         if (millisecondsTimeout < Timeout.Infinite)
         {
             throw new ArgumentOutOfRangeException();
         }
         var ao = new object[] { toSignal, toWaitOn };
         manager.SetMethodInfo("WaitHandle.SignalAndWait");
         manager.AggregateSyncVarAccess(ao, MSyncVarOp.RWVAR_READWRITE);
         bool ret = Original::WaitHandle.SignalAndWait(toSignal, toWaitOn, 0, false);
         if (!ret)
         {
             manager.MarkTimeout();
         }
         manager.CommitSyncVarAccess();
         if (ret)
         {
             return true;
         }
         if (!(millisecondsTimeout <= Timeout.Infinite))
         {
             manager.TaskYield();
             return false;
         }
         var ah = new Original::WaitHandle[] { toWaitOn };
         return (WaitHandleHelper.WaitGeneralRaw(manager, ah, millisecondsTimeout, exitContext, "WaitOne") != Original::WaitHandle.WaitTimeout);
     },
                delegate()
     {
         return Original::WaitHandle.SignalAndWait(toSignal, toWaitOn, millisecondsTimeout, exitContext);
     }));
 }
Exemple #3
0
 public static bool WaitAll(Original::WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
 {
     return(WaitHandleHelper.WaitGeneral(waitHandles, millisecondsTimeout, exitContext, "WaitAll") != Original::WaitHandle.WaitTimeout);
 }
Exemple #4
0
 public static int WaitAny(Original::WaitHandle[] waitHandles, int millisecondsTimeout, bool exitContext)
 {
     return(WaitHandleHelper.WaitGeneral(waitHandles, millisecondsTimeout, exitContext, "WaitAny"));
 }