コード例 #1
0
        public void Release(int units)
        {
            bool wasInterrupted;

            SyncUtils.EnterUninterruptibly(mon, out wasInterrupted);
            try
            {
                counter += units;
                grantAllAvailable();
            }
            finally
            {
                Monitor.Exit(mon);
                if (wasInterrupted)
                {
                    Thread.CurrentThread.Interrupt();
                }
            }
        }
コード例 #2
0
 public void Set()
 {
     signaled = true;
     Interlocked.MemoryBarrier();
     if (waiters != 0)
     {
         SyncUtils.EnterUninterruptibly(mon, out bool wasInterrupted);
         setVersion += 1;
         try
         {
             Monitor.PulseAll(mon);
         }
         finally
         {
             Monitor.Exit(mon);
             if (wasInterrupted)
             {
                 Thread.CurrentThread.Interrupt();
             }
         }
     }
 }