public bool TryEnter(TimeSpan timeout) { AsyncWaitHandle waiter = EnterCore(); if (waiter != null) { bool timedOut = !waiter.Wait(timeout); if (this.aborted) { throw Fx.Exception.AsError(CreateObjectAbortedException()); } if (timedOut && !RemoveWaiter(waiter)) { // The timeout raced with Exit and exit won. // We've successfully entered. timedOut = false; } return(!timedOut); } return(true); }
public bool TryEnter(TimeSpan timeout) { AsyncWaitHandle asyncWaitHandle = this.EnterCore(); if (asyncWaitHandle == null) { return(true); } else { bool flag = !asyncWaitHandle.Wait(timeout); if (!this.aborted) { if (flag && !this.RemoveWaiter(asyncWaitHandle)) { flag = false; } return(!flag); } else { throw Fx.Exception.AsError(this.CreateObjectAbortedException()); } } }
public bool TryEnter(TimeSpan timeout) { AsyncWaitHandle waiter = this.EnterCore(); if (waiter == null) { return(true); } bool flag = !waiter.Wait(timeout); if (this.aborted) { throw Fx.Exception.AsError(this.CreateObjectAbortedException()); } if (flag && !this.RemoveWaiter(waiter)) { flag = false; } return(!flag); }