This is the only real work to be done, once we've acquired the write lock we have to wait for all readers to complete. If/when that happens we can then own the write lock. The case where this does not take place is when a thread that already owns the lock calls us to lock again. In this case we can just return success and ignore the outstanding read requests. The major problem with this approach is that if function A() does a read-lock and calls function B() which does a write lock, this will fail. So the solution is to either use the upgradeable version (see the derived class UpgradableReadWriteLocking) and upgrade, or to start with a write lock in function A().
Syntax
Parameters
- targetReaders
- millisecondsTimeout
Requirements
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
See Also