tags:

views:

321

answers:

2

The documentation of ReaderWriterLockSlim.EnterUpgradeableReadLock says:

A thread in upgradeable mode can downgrade to read mode or upgrade to write mode.

How do I downgrade the lock to a read lock? The documentation does't tell...

[Edit:] I'm not trying to get the write lock. I just want to downgrade the upgradeable lock to a read lock so that another thread can acquire the upgradeable lock.

A: 

It's automatic - the lock will upgrade to writeable when necessary. You don't have to do anything. It's a read lock unless you request writing.

Mike Scott
Thanks, but I'm not trying to acquire the write lock. I just want to downgrade the upgradeable lock to a read lock so that another thread can acquire the upgradeable lock.
Hosam Aly
+1  A: 

According to the MSDN documentation for ReaderWriterLockSlim (the class itself):

"A thread in upgradeable mode can downgrade to read mode by first calling the EnterReadLock method and then calling the ExitUpgradeableReadLock method."

Eric Rosenberger
My mistake for not reading the documentation till the end. Thanks!
Hosam Aly