PartitionedRateLimiter<TResource>.AcquireAsync 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 (TResource resource, int permitCount = 1, System.Threading.CancellationToken cancellationToken = default);
member this.AcquireAsync : 'Resource * int * System.Threading.CancellationToken -> System.Threading.Tasks.ValueTask<System.Threading.RateLimiting.RateLimitLease>
Public Function AcquireAsync (resource As TResource, Optional permitCount As Integer = 1, Optional cancellationToken As CancellationToken = Nothing) As ValueTask(Of RateLimitLease)

Parameters

resource
TResource

The resource to limit.

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