uncertainty, do so. Therefore, I recommend against locking via the this keyword, and I suggest
instead using a private instance of System.Object as your lock. You could achieve the same effect if
there were some way to declare the sync block flag of an object private, but alas, that is not possible.
Beware of Boxing
When you’re using the Monitor methods to implement locking, internally Monitor uses the sync
block of object instances to manage the lock. Since every object instance can potentially have a
sync block, you can use any reference to an object, even an object reference to a boxed value. Even
though you can, you should never pass a value type instance to Monitor.Enter, as demonstrated in
the following code example:
using System;
using System.Threading; ...