Gemstone Threading Library
Show/Hide TOC

# AsyncLockTryEnterAsync(Int32) Method

Attempts to obtain exclusive access to the lock.

## Definition

Namespace: Gemstone.Threading
Assembly: Gemstone.Threading (in Gemstone.Threading.dll) Version: 1.0.155 -- Release Build+fbb54a9347e09f19695376cbf86e09a9ff9ee9ca
C#
View Source Request Example

    public Task<IDisposable> TryEnterAsync(
    	int milliseconds
    )

VB
View Source Request Example

    Public Function TryEnterAsync (
    	milliseconds As Integer
    ) As Task(Of IDisposable)

C++
View Source Request Example

    public:
    Task<IDisposable^>^ TryEnterAsync(
    	int milliseconds
    )

JavaScript
View Source Request Example

    function TryEnterAsync(milliseconds);

#### Parameters

milliseconds Int32
  The number of milliseconds to wait before failing to take the lock.

#### Return Value

Task IDisposable
A task that, if cancelled, indicates the lock was not taken, and must be awaited to obtain the token that will release the lock on Dispose.

## Exceptions

TaskCanceledException | The timeout expires before the lock could be taken.

## See Also

#### Reference

AsyncLock Class
TryEnterAsync Overload
Gemstone.Threading Namespace