In Java there are ThreadMXBean and ThreadInfo to requests information over the locks that a thread is holding at runtime.
Is this also possible with C#? If yes how can I do it?
There isn't a runtime equivalent in C#. If you need to track it you'll need to implement you're own wrapper around it. Also consider using Monitor.TryEnter with a timeout if your application is sensitive to locking.
lock (object)
{
// Synchronized code
}
Translates to,
try
{
Monitor.Enter(object);
}
finally
{
Monitor.Exit(object);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With