Created
November 9, 2011 18:25
-
-
Save jeremydmiller/1352358 to your computer and use it in GitHub Desktop.
This file contains 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
public static class ReaderWriterLockExtensions | |
{ | |
public static void Write(this ReaderWriterLockSlim rwLock, Action action) | |
{ | |
rwLock.EnterWriteLock(); | |
try | |
{ | |
action(); | |
} | |
finally | |
{ | |
rwLock.ExitWriteLock(); | |
} | |
} | |
public static void Read(this ReaderWriterLockSlim rwLock, Action action) | |
{ | |
rwLock.EnterReadLock(); | |
try | |
{ | |
action(); | |
} | |
finally | |
{ | |
rwLock.ExitReadLock(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment