Gemstone Threading Library
Show/Hide TOC

# AsyncLockTryEnterAsync Method

Attempts to obtain exclusive access to the lock.

## Definition

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

    public Task<IDisposable> TryEnterAsync()

VB
View Source Request Example

    Public Function TryEnterAsync As Task(Of IDisposable)

C++
View Source Request Example

    public:
    Task<IDisposable^>^ TryEnterAsync()

JavaScript
View Source Request Example

    function TryEnterAsync();

#### 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 lock could not be taken.

## See Also

#### Reference

AsyncLock Class
TryEnterAsync Overload
Gemstone.Threading Namespace