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

RetryTResultSyntax

public static class RetryTResultSyntax
Fluent API for defining a Retry Policy.
public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder)

Builds a Policy that will retry once.

public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount)

Builds a Policy that will retry retryCount times.

public static RetryPolicy<TResult> Retry<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int> onRetry)

Builds a Policy that will retry once calling onRetry on retry with the handled exception or result and retry count.

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

Builds a Policy that will retry retryCount times calling onRetry on each retry with the handled exception or result and retry count.

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

Builds a Policy that will retry once calling onRetry on retry with the handled exception or result, retry count and context data.

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

Builds a Policy that will retry retryCount times calling onRetry on each retry with the handled exception or result, retry count and context data.

public static RetryPolicy<TResult> RetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder)

Builds a Policy that will retry indefinitely.

public static RetryPolicy<TResult> RetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<Exception> onRetry)

Builds a Policy that will retry indefinitely calling onRetry on each retry with the handled exception or result.

public static RetryPolicy<TResult> RetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, Context> onRetry)

Builds a Policy that will retry indefinitely calling onRetry on each retry with the handled exception or result and context data.

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

Builds a Policy that will wait and retry retryCount times. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry attempt allowing an exponentially increasing wait time (exponential backoff).

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

Builds a Policy 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 attempt allowing an exponentially increasing wait time (exponential backoff).

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

Builds a Policy that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result, current sleep duration and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry attempt allowing an exponentially increasing wait time (exponential backoff).

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

Builds a Policy that will wait and retry retryCount times calling onRetry on each retry with the handled exception or result, current sleep duration, retry count, and context data. On each retry, the duration to wait is calculated by calling sleepDurationProvider with the current retry attempt allowing an exponentially increasing wait time (exponential backoff).

public static RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations)

Builds a Policy 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 RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan> onRetry)

Builds a Policy 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 RetryPolicy<TResult> WaitAndRetry<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan, Context> onRetry)

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

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

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

public static RetryPolicy<TResult> WaitAndRetryForever<TResult>(this PolicyBuilder<TResult> policyBuilder, Func<int, TimeSpan> sleepDurationProvider)

Builds a Policy that will wait and retry indefinitely.

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

Builds a Policy that will wait and retry indefinitely calling onRetry on each retry with the handled exception or result.

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

Builds a Policy that will wait and retry indefinitely calling onRetry on each retry with the handled exception or result and execution context.