<PackageReference Include="Polly" Version="7.2.2" />

AsyncRetryTResultSyntax

public static class AsyncRetryTResultSyntax
Fluent API for defining an AsyncRetryPolicy<T>.
public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder)

Builds an AsyncRetryPolicy<T> that will retry once.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount)

Builds an AsyncRetryPolicy<T> that will retry retryCount times.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int> onRetry)

Builds an AsyncRetryPolicy<T> that will retry once calling onRetry on retry with the handled exception or result and retry count.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, int, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry once calling onRetryAsync on retry with the handled exception or result and retry count.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Action<DelegateResult<TResult>, int> onRetry)

Builds an AsyncRetryPolicy<T> that will retry retryCount times calling onRetry on each retry with the handled exception or result and retry count.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<DelegateResult<TResult>, int, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry retryCount times calling onRetryAsync on each retry with the handled exception or result and retry count.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will retry once calling onRetry on retry with the handled exception or result, retry count and context data.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry once calling onRetryAsync on retry with the handled exception or result, retry count and context data.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Action<DelegateResult<TResult>, int, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will retry retryCount times calling onRetry on each retry with the handled exception or result, retry count and context data.

public static AsyncRetryPolicy<TResult> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<DelegateResult<TResult>, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry retryCount times calling onRetryAsync on each retry with the handled exception or result, retry count and context data.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder)

Builds an AsyncRetryPolicy<T> that will retry indefinitely until the action succeeds.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>> onRetry)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetry on each retry with the handled exception or result.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int> onRetry)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetry on each retry with the handled exception or result and retry count.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetryAsync on each retry with the handled exception or result.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, int, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetryAsync on each retry with the handled exception or result and retry count.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetry on each retry with the handled exception or result and context data.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetry on each retry with the handled exception or result, retry count and context data.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetryAsync on each retry with the handled exception or result and context data.

public static AsyncRetryPolicy<TResult> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<DelegateResult<TResult>, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will retry indefinitely calling onRetryAsync on each retry with the handled exception or result, retry count and context data.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result and the current sleep duration. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc)

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetryAsync on each retry with the handled exception or result and the current sleep duration. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result, the current sleep duration and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetryAsync on each retry with the handled exception or result, the current sleep duration and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetryAsync on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result, the current sleep duration and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetryAsync on each retry with the handled exception or result, the current sleep duration and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetryAsync on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, DelegateResult<TResult>, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry retryCount times calling onRetryAsync on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc), result of previous execution, and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations calling onRetry on each retry with the handled exception or result and the current sleep duration. On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<DelegateResult<TResult>, TimeSpan, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations calling onRetryAsync on each retry with the handled exception or result and the current sleep duration. On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations calling onRetry on each retry with the handled exception or result, the current sleep duration and context data. On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<DelegateResult<TResult>, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations calling onRetryAsync on each retry with the handled exception or result, the current sleep duration and context data. On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan, int, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations calling onRetry on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry as many times as there are provided sleepDurations calling onRetryAsync on each retry with the handled exception or result, the current sleep duration, retry count, and context data. On each retry, the duration to wait is the current sleepDurations item.

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetry on each retry with the handled exception or result. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, int, TimeSpan> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetry on each retry with the handled exception or result. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, int, TimeSpan, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result and retry count. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc).

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetry on each retry with the handled exception or result and execution context. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, int, TimeSpan, Context> onRetry)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetry on each retry with the handled exception or result and execution context. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result and execution context. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, int, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result, retry count and execution context. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc) and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, DelegateResult<TResult>, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result and execution context. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context.

public static AsyncRetryPolicy<TResult> WaitAndRetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, DelegateResult<TResult>, Context, TimeSpan> sleepDurationProvider, Func<DelegateResult<TResult>, int, TimeSpan, Context, Task> onRetryAsync)

Builds an AsyncRetryPolicy<T> that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result, retry count and execution context. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry number (1 for first retry, 2 for second etc), previous execution result and execution context.