Compartilhar via


AsyncSemaphore.EnterAsync Method

Definition

Overloads

EnterAsync(CancellationToken)

Requests access to the lock.

EnterAsync(Int32, CancellationToken)

Requests access to the lock.

EnterAsync(TimeSpan, CancellationToken)

Requests access to the lock.

EnterAsync(CancellationToken)

Requests access to the lock.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncSemaphore.Releaser> EnterAsync (System.Threading.CancellationToken cancellationToken = default);
member this.EnterAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncSemaphore.Releaser>
Public Function EnterAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of AsyncSemaphore.Releaser)

Parameters

cancellationToken
CancellationToken

A token whose cancellation signals lost interest in the lock.

Returns

A task whose result is a releaser that should be disposed to release the lock. This task may be canceled if cancellationToken is signaled.

Exceptions

Thrown when cancellationToken is canceled before semaphore access is granted.

Thrown when this semaphore is disposed before semaphore access is granted.

Applies to

EnterAsync(Int32, CancellationToken)

Requests access to the lock.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncSemaphore.Releaser> EnterAsync (int timeout, System.Threading.CancellationToken cancellationToken = default);
member this.EnterAsync : int * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncSemaphore.Releaser>
Public Function EnterAsync (timeout As Integer, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AsyncSemaphore.Releaser)

Parameters

timeout
Int32

A timeout for waiting for the lock (in milliseconds).

cancellationToken
CancellationToken

A token whose cancellation signals lost interest in the lock.

Returns

A task whose result is a releaser that should be disposed to release the lock.

Exceptions

Thrown when cancellationToken is canceled or the timeout expires before semaphore access is granted.

Thrown when this semaphore is disposed before semaphore access is granted.

Applies to

EnterAsync(TimeSpan, CancellationToken)

Requests access to the lock.

public System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncSemaphore.Releaser> EnterAsync (TimeSpan timeout, System.Threading.CancellationToken cancellationToken = default);
member this.EnterAsync : TimeSpan * System.Threading.CancellationToken -> System.Threading.Tasks.Task<Microsoft.VisualStudio.Threading.AsyncSemaphore.Releaser>
Public Function EnterAsync (timeout As TimeSpan, Optional cancellationToken As CancellationToken = Nothing) As Task(Of AsyncSemaphore.Releaser)

Parameters

timeout
TimeSpan

A timeout for waiting for the lock.

cancellationToken
CancellationToken

A token whose cancellation signals lost interest in the lock.

Returns

A task whose result is a releaser that should be disposed to release the lock. This task may be canceled if cancellationToken is signaled or timeout expires.

Exceptions

Thrown when cancellationToken is canceled or the timeout expires before semaphore access is granted.

Thrown when this semaphore is disposed before semaphore access is granted.

Applies to