How to request thread locks and deadlocks at runtime using C #?

Java has ThreadMXBean and ThreadInfo to request information about the locks that the thread supports at run time.

Is this also possible with C #? If so, how can I do this?

+5
source share
1 answer

There is no runtime equivalent in C #. If you need to track it, you will need to implement your own shell. Also consider using Monitor.TryEnter with a timeout if your application is sensitive to blocking.

lock (object) { // Synchronized code }

Translates

try
{
    Monitor.Enter(object);
}
finally
{
    Monitor.Exit(object);
}

code>

+1
source

All Articles