Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified object.
true if the current thread acquires the lock; otherwise, false.
Type Reason ArgumentNullException obj is null. ArgumentOutOfRangeException millisecondsTimeout is negative, and not equal to Timeout.Infinite .
If the millisecondsTimeout parameter equals Timeout.Infinite, this method is equivalent to Monitor.Enter(object). If millisecondsTimeout equals 0, this method is equivalent to Monitor.TryEnter(object).
Use System.Threading.Monitor to lock objects (that is, reference types), not value types. For details, see Monitor.Enter(object) and the conceptual topic [<topic://cpconMonitor>].