![]()
true if the current thread acquires the lock; otherwise, false.
Type Reason ArgumentNullException obj is null. ArgumentOutOfRangeException The value of timeout in milliseconds is negative and is not equal to Timeout.Infinite , or is greater than int.MaxValue .
If the value of the timeout parameter converted to milliseconds equals –1, this method is equivalent to Monitor.Enter(object). If the value of timeout 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>].