Created
November 1, 2011 14:08
-
-
Save kumpera/1330573 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Threading; | |
namespace RWLockSlimTest | |
{ | |
class MainClass | |
{ | |
public static void Main(string[] args) | |
{ | |
ReaderWriterLockSlim rwlock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion); | |
rwlock.EnterWriteLock (); | |
rwlock.EnterUpgradeableReadLock (); | |
rwlock.ExitUpgradeableReadLock (); | |
rwlock.ExitWriteLock (); | |
/* The next statement fails with | |
Unhandled Exception: System.Threading.LockRecursionException: In read mode you can just enter Read recursively | |
at System.Threading.ReaderWriterLockSlim.CheckRecursionAuthorization (LockState ctstate, LockState desiredState) [0x00000] in <filename unknown>:0 | |
at System.Threading.ReaderWriterLockSlim.CheckState (System.Threading.ThreadLockState state, Int32 millisecondsTimeout, LockState validState) [0x00000] in <filename unknown>:0 | |
at System.Threading.ReaderWriterLockSlim.TryEnterWriteLock (Int32 millisecondsTimeout) [0x00000] in <filename unknown>:0 | |
at System.Threading.ReaderWriterLockSlim.EnterWriteLock () [0x00000] in <filename unknown>:0 | |
at RWLockSlimTest.MainClass.Main (System.String[] args) [0x00000] in <filename unknown>:0 | |
*/ | |
rwlock.EnterWriteLock (); | |
//rwlock.ExitWriteLock (); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment