Dela via


RateLimiter.AcquireAsync(Int32, CancellationToken) Method

Definition

Wait until the requested permits are available or permits can no longer be acquired.

public System.Threading.Tasks.ValueTask<System.Threading.RateLimiting.RateLimitLease> AcquireAsync (int permitCount = 1, System.Threading.CancellationToken cancellationToken = default);
member this.AcquireAsync : int * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Threading.RateLimiting.RateLimitLease>
Public Function AcquireAsync (Optional permitCount As Integer = 1, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of RateLimitLease)

Parameters

permitCount
Int32

Number of permits to try and acquire.

cancellationToken
CancellationToken

Optional token to allow canceling a queued request for permits.

Returns

A task that completes when the requested permits are acquired or when the requested permits are denied.

Exceptions

Remarks

Set permitCount to 0 to wait until permits are replenished.

Applies to