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
Monitor is more flexible. My favorite use case of using monitor is when you don't want to wait for your turn and just skip:
//already executing? forget it, lets move on if(Monitor.TryEnter(_lockObject)) { //do stuff; Monitor.Exit(_lockObject); }