Gemstone Common Library
Show/Hide TOC

# InterprocessReaderWriterLockTryEnterReadLock Method

Tries to enter the lock in read mode, with an optional time-out.

## Definition

Namespace: Gemstone.Threading
Assembly: Gemstone.Common (in Gemstone.Common.dll) Version: 1.0.175 -- Release Build+70cfebd19f80455d07e1cf93607e59f6af0e38f4
C#
View Source Request Example

    public bool TryEnterReadLock(
    	int millisecondsTimeout
    )

VB
View Source Request Example

    Public Function TryEnterReadLock (
    	millisecondsTimeout As Integer
    ) As Boolean

C++
View Source Request Example

    public:
    bool TryEnterReadLock(
    	int millisecondsTimeout
    )

JavaScript
View Source Request Example

    function TryEnterReadLock(millisecondsTimeout);

#### Parameters

millisecondsTimeout Int32
  The number of milliseconds to wait, or -1 (Infinite) to wait indefinitely.

#### Return Value

Boolean
true if the calling thread entered read mode, otherwise, false.

## Remarks

Upon successful acquisition of a read lock, use the finally block of a try/finally statement to call ExitReadLock. One ExitReadLock should be called for each EnterReadLock or TryEnterReadLock(Int32).

Note that this function may wait as long as 2 * millisecondsTimeout since the function first waits for synchronous access to the semaphore, then waits again on an available semaphore slot.

## See Also

#### Reference

InterprocessReaderWriterLock Class
Gemstone.Threading Namespace