/// <summary> /// Acquires a reader lock. /// </summary> /// <returns>An object (considered opaque by client code) that should be disposed /// once the lock is not needed.</returns> /// <remarks>It is strongly recommended to use the <b>using</b> construct with /// this method.</remarks> public Cookie AcquireReadLock() { if (this.@lock == null) { return(new Cookie(CookieAction.None, null, null)); } CookieAction action; if ([email protected] && [email protected] && [email protected]) { action = CookieAction.ExitReadLock; DeadlockMonitor.EnterWaiting(@lock, writeLock, lockedObject); if ([email protected](WarningTimeout)) { Debug.Print("Acquiring a read lock on {0} from thread {1} ({2}) is taking longer than expected.", lockedObject, Thread.CurrentThread.ManagedThreadId, Thread.CurrentThread.Name); DeadlockMonitor.DetectDeadlocks(); @lock.EnterReadLock(); } DeadlockMonitor.ExitWaiting(@lock, writeLock); DeadlockMonitor.EnterAcquired(@lock, readLock, lockedObject); } else { action = CookieAction.None; } return(new Cookie(action, this, GetStackTrace())); }