private void RecoverLock(ref LockCookie lockCookie, LockCookieFlags flags)
{
// Contrary to the legacy code, this method does not use a finite timeout for recovering the previous lock state, as
// a timeout would leave the lock in an inconsistent state. That possibility is not documented, but as documented,
// the caller of the public entry method should expect that it does not return until the state is consistent.
// Check if the thread was a writer
if ((flags & LockCookieFlags.OwnedWriter) != 0)
{
// Acquire writer lock
AcquireWriterLock(Timeout.Infinite);
_writerLevel = lockCookie._writerLevel;
}
// Check if the thread was a reader
else if ((flags & LockCookieFlags.OwnedReader) != 0)
{
AcquireReaderLock(Timeout.Infinite);
ThreadLocalLockEntry threadLocalLockEntry = ThreadLocalLockEntry.GetCurrent(_lockID);
Debug.Assert(threadLocalLockEntry != null);
threadLocalLockEntry._readerLevel = lockCookie._readerLevel;
}
}