When is it appropriate to use either the Monitor class or the lock keyword for thread safety in C#?
Monitor
lock
EDIT: It seems from th
lock is just shortcut for Monitor.Enter with try + finally and Monitor.Exit. Use lock statement whenever it is enough - if you need something like TryEnter, you will have to use Monitor.
Monitor.Enter
try
finally
Monitor.Exit