NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Monitor.TryEnter (Object, Int32)

Version of TryEnter that will block, but only up to a timeout period expressed in milliseconds.

[Visual Basic]
Overloads Public Shared Function TryEnter( _
   ByVal obj As Object, _
   ByVal millisecondsTimeout As Integer _
) As Boolean
[C#]
public static bool TryEnter(
   object obj,
   int millisecondsTimeout
);
[C++]
public: static bool TryEnter(
   Object* obj,
   int millisecondsTimeout
);
[JScript]
public static function TryEnter(
   obj : Object,
   millisecondsTimeout : int
) : Boolean;

Parameters

obj
Object on which to acquire the monitor lock.
millisecondsTimeout
[To be supplied.]

Return Value

True if the current thread can acquire the monitor lock without blocking; otherwise, False.

Exceptions

Exception Type Condition
ArgumentNullException If obj is a null reference (in Visual Basic Nothing).
ArgumentException If obj is a value type.
ArgumentException If millisecondsTimeout is negative.

Remarks

If millisecondsTimeout equals Infinite, this method becomes equivalent to Enter.

See Also

Monitor Class | Monitor Members | System.Threading Namespace | Monitor.TryEnter Overload List | Thread