KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a situation whereby ReadWriterLockSlim is throwing the exception "System.Threading.SynchronizationLockException - The write lock is being released without being held." when I try to execute ExitWriteLock(). As far as I can tell, this shouldn't happen because subsequent threads that enter the try block will 'block' until they can obtain the lock. Am I missing something here? The issue looks very similar to this one , however no solution was posted there. //Code simplified for example. public class i18nService { internal static ReaderWriterLockSlim cacheLock = new ReaderWriterLockSlim(LockRecursionPolicy.NoRecursion); private string ProcessText() { try { cacheLock.EnterWriteLock(); return "xyz"; } finally { cacheLock.ExitWriteLock(); // Error is throwing here. } } } Thanks very much for your help :-)
Tags (comma-separated)
Save Edits
Cancel