Monitor.TryEnter Method (Object, Int32)
.NET Framework 4.5
Attempts, for the specified number of milliseconds, to acquire an exclusive lock on the specified object.
Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Parameters
- obj
- Type: System.Object
The object on which to acquire the lock.
- millisecondsTimeout
- Type: System.Int32
The number of milliseconds to wait for the lock.
| Exception | Condition |
|---|---|
| ArgumentNullException | The obj parameter is null. |
| ArgumentOutOfRangeException | millisecondsTimeout is negative, and not equal to Infinite. |
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note