In a debugger I “froze” when executing such line of code: lock (myvar) Obviously someone else is holding myvar. However I expect at this line that myvar should be free. So I want to know which part of code holdes myvar (from another thread diffenetely). How can I do that? I know which thread holdes it (because I have only one another thread) but I don’t know where.
upd solved, I forgot to call Monitor.Exit(myvar) after one Monitor.TryEnter(myvar)
The
lock()statement uses theMonitorclass which does not support querying the locking threads.In Fx 4.5 you can check
Monitor.IsEntered(myVar)but that’s about it.The rest should come from your code’s logic.