ReaderWriterLock doc ambiguity

Found in the ReaderWriterLock MSDN documentation:

AcquireReaderLock supports recursive reader-lock requests. That is, a thread can call AcquireReaderLock multiple times, which increments the lock count each time. You must call ReleaseReaderLock once for each time you call AcquireReaderLock.

My question is: If you set a finite timeout on the AcquireReaderLock and that a ApplicationException is thrown, should the release method be called anyway

Intuitively, I would answer No to this question. Does anyone know the right answer for sure

Thanks in advance,
Joannes


Answer this question

ReaderWriterLock doc ambiguity

  • Nanook

    The answer is No. You should only release the lock if you successfully acquired it.

    joe

  • ReaderWriterLock doc ambiguity