ReaderWriterLockSlim.TryEnterUpgradeableReadLock (0) is blocking
In my .Net application, I have a place where I declare ReaderWriterLockSlim
:
private readonly ReaderWriterLockSlim m_lock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);
Elsewhere I update some value every 100ms, so basically if once, the lock is not available, it doesn't really matter, I just want to exit and wait for the next call.
So, I have the following method content:
if (m_lock.TryEnterUpgradeableReadLock(0)){
..
}
In the application I currently have locks (which doesn't seem to have anything to do with this current issue), so I paused my application to check the threads and I saw that I have over 20 threads that are currently blocked in the if condition.
This is very strange because the documentation is very clear:
If the millisecondsTimeout is 0 (zero), this method checks the blocking state and returns false immediately if the desired state is not available.
The question is simple. WHYYYYYYYYYYYYYYYYYY? I tried to put breakpoints after TryEnterUpgradeable
to continue, but that doesn't work.
source to share
No one has answered this question yet
Check out similar questions: