Attempts to acquire the monitor lock without blocking.
[Visual Basic] Overloads Public Shared Function TryEnter( _ ByVal obj As Object _ ) As Boolean [C#] public static bool TryEnter( object obj ); [C++] public: static bool TryEnter( Object* obj ); [JScript] public static function TryEnter( obj : Object ) : Boolean;
True if the current thread can acquire the monitor lock without blocking; otherwise, False.
Exception Type | Condition |
---|---|
ArgumentNullException | If obj is a null reference (in Visual Basic Nothing). |
ArgumentException | If obj is a value type. |
This method is similar to Enter, but it will never block. If the thread cannot enter without blocking, false is returned and the thread does not enter the critical section.
Monitor Class | Monitor Members | System.Threading Namespace | Monitor.TryEnter Overload List | Thread