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); }
public void Enter() { ThreadNeutralSemaphore.SyncWaiter syncWaiter = this.EnterCore(); if (syncWaiter != null) { syncWaiter.Wait(); } }
public bool TryEnter(TimeSpan timeout) { ThreadNeutralSemaphore.SyncWaiter syncWaiter = this.EnterCore(); if (syncWaiter == null) { return(true); } return(syncWaiter.Wait(timeout)); }