Пример #1
0
 private ThreadNeutralSemaphore.SyncWaiter EnterCore()
 {
     ThreadNeutralSemaphore.SyncWaiter syncWaiter;
     lock (this.ThisLock)
     {
         if (this.aborted)
         {
             throw Microsoft.ServiceBus.Diagnostics.DiagnosticUtility.ExceptionUtility.ThrowHelperError(ThreadNeutralSemaphore.CreateObjectAbortedException());
         }
         if (this.count >= this.maxCount)
         {
             if (this.traceOnFailureToEnter)
             {
                 this.IncrementFailureCount();
             }
             ThreadNeutralSemaphore.SyncWaiter syncWaiter1 = new ThreadNeutralSemaphore.SyncWaiter(this);
             this.Waiters.Enqueue(syncWaiter1);
             return(syncWaiter1);
         }
         else
         {
             ThreadNeutralSemaphore threadNeutralSemaphore = this;
             threadNeutralSemaphore.count = threadNeutralSemaphore.count + 1;
             syncWaiter = null;
         }
     }
     return(syncWaiter);
 }
Пример #2
0
 public void Enter()
 {
     ThreadNeutralSemaphore.SyncWaiter syncWaiter = this.EnterCore();
     if (syncWaiter != null)
     {
         syncWaiter.Wait();
     }
 }
Пример #3
0
 public bool TryEnter(TimeSpan timeout)
 {
     ThreadNeutralSemaphore.SyncWaiter syncWaiter = this.EnterCore();
     if (syncWaiter == null)
     {
         return(true);
     }
     return(syncWaiter.Wait(timeout));
 }