<PackageReference Include="Microsoft.Rest.ClientRuntime" Version="2.3.16" />

Microsoft.Rest.TransientFaultHandling.RetryPolicy

public class RetryPolicy
Provides the base implementation of the retry mechanism for unreliable actions and transient conditions.

Gets the instance of the error detection strategy.

public int EventCallbackCount { get; }

Get delegate count associated with the event

public RetryStrategy RetryStrategy { get; }

Gets the retry strategy.

An instance of a callback delegate that will be invoked whenever a retry condition is encountered.

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, RetryStrategy retryStrategy)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and default fixed time interval between retries.

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan retryInterval)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and fixed time interval between retries.

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and backoff parameters for calculating the exponential delay between retries.

public RetryPolicy(ITransientErrorDetectionStrategy errorDetectionStrategy, int retryCount, TimeSpan initialInterval, TimeSpan increment)

Initializes a new instance of the RetryPolicy class with the specified number of retry attempts and parameters defining the progressive delay between retries.

public virtual void ExecuteAction(Action action)

Repetitively executes the specified action while it satisfies the current retry policy.

public virtual TResult ExecuteAction<TResult>(Func<TResult> func)

Repetitively executes the specified action while it satisfies the current retry policy.

public Task ExecuteAsync(Func<Task> taskAction)

Repetitively executes the specified asynchronous task while it satisfies the current retry policy.

public Task ExecuteAsync(Func<Task> taskAction, CancellationToken cancellationToken)

Repetitively executes the specified asynchronous task while it satisfies the current retry policy.

public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> taskFunc)

Repeatedly executes the specified asynchronous task while it satisfies the current retry policy.

public Task<TResult> ExecuteAsync<TResult>(Func<Task<TResult>> taskFunc, CancellationToken cancellationToken)

Repeatedly executes the specified asynchronous task while it satisfies the current retry policy.

protected virtual void OnRetrying(int retryCount, Exception lastError, TimeSpan delay)

Notifies the subscribers whenever a retry condition is encountered.