Table of Contents

Class RetryTResultSyntaxAsync

Namespace
Polly
Assembly
Polly.dll

Fluent API for defining a Retry Policy.

public static class RetryTResultSyntaxAsync
Inheritance
RetryTResultSyntaxAsync
Inherited Members

Methods

RetryAsync<TResult>(PolicyBuilder<TResult>)

Builds a Policy that will retry once.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

RetryAsync<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>, int, Context>)

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> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, int, Context> onRetry)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetry Action<DelegateResult<TResult>, int, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetry

RetryAsync<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>, int>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetry Action<DelegateResult<TResult>, int>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetry

RetryAsync<TResult>(PolicyBuilder<TResult>, Func<DelegateResult<TResult>, int, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetryAsync Func<DelegateResult<TResult>, int, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetry

RetryAsync<TResult>(PolicyBuilder<TResult>, Func<DelegateResult<TResult>, int, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetryAsync Func<DelegateResult<TResult>, int, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetry

RetryAsync<TResult>(PolicyBuilder<TResult>, int)

Builds a Policy that will retry retryCount times.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

RetryAsync<TResult>(PolicyBuilder<TResult>, int, Action<DelegateResult<TResult>, int, Context>)

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> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Action<DelegateResult<TResult>, int, Context> onRetry)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

onRetry Action<DelegateResult<TResult>, int, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than zero.

ArgumentNullException

onRetry

RetryAsync<TResult>(PolicyBuilder<TResult>, int, Action<DelegateResult<TResult>, int>)

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> RetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Action<DelegateResult<TResult>, int> onRetry)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

onRetry Action<DelegateResult<TResult>, int>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

onRetry

RetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<DelegateResult<TResult>, int, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

onRetryAsync Func<DelegateResult<TResult>, int, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than zero.

ArgumentNullException

onRetryAsync

RetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<DelegateResult<TResult>, int, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

onRetryAsync Func<DelegateResult<TResult>, int, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

onRetryAsync

RetryForeverAsync<TResult>(PolicyBuilder<TResult>)

Builds a Policy that will retry indefinitely until the action succeeds.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

RetryForeverAsync<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>, Context>)

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> RetryForeverAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, Action<DelegateResult<TResult>, Context> onRetry)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetry Action<DelegateResult<TResult>, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetry

RetryForeverAsync<TResult>(PolicyBuilder<TResult>, Action<DelegateResult<TResult>>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetry Action<DelegateResult<TResult>>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetry

RetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<DelegateResult<TResult>, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetryAsync Func<DelegateResult<TResult>, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetryAsync

RetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<DelegateResult<TResult>, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

onRetryAsync Func<DelegateResult<TResult>, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>)

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> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)

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, the current sleep duration and context data. On each retry, the duration to wait is the current sleepDurations item.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

onRetry Action<DelegateResult<TResult>, TimeSpan, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurations or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, int, Context>)

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, the current sleep duration, retry count, and context data. On each retry, the duration to wait is the current sleepDurations item.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

onRetry Action<DelegateResult<TResult>, TimeSpan, int, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurations or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Action<DelegateResult<TResult>, TimeSpan>)

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> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<DelegateResult<TResult>, TimeSpan> onRetry)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

onRetry Action<DelegateResult<TResult>, TimeSpan>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurations or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Context, Task>)

Builds a Policy 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 RetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<DelegateResult<TResult>, TimeSpan, Context, Task> onRetryAsync)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurations or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task>)

Builds a Policy 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 RetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task> onRetryAsync)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, int, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurations or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, IEnumerable<TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Task>)

Builds a Policy 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 RetryPolicy<TResult> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<DelegateResult<TResult>, TimeSpan, Task> onRetryAsync)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurations IEnumerable<TimeSpan>

The sleep durations to wait for on each retry.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurations or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, Context, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetry Action<DelegateResult<TResult>, TimeSpan, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, int, Context>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, Context, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetry Action<DelegateResult<TResult>, TimeSpan, int, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, Context, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, Context, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, Context, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, int, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>)

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> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetry Action<DelegateResult<TResult>, TimeSpan, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, int, Context>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetry Action<DelegateResult<TResult>, TimeSpan, int, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan>)

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> WaitAndRetryAsync<TResult>(this PolicyBuilder<TResult> policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<DelegateResult<TResult>, TimeSpan> onRetry)

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetry Action<DelegateResult<TResult>, TimeSpan>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetry

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, int, Context, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, int, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetryAsync

WaitAndRetryAsync<TResult>(PolicyBuilder<TResult>, int, Func<int, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Task>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

retryCount int

The retry count.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentOutOfRangeException

retryCount;Value must be greater than or equal to zero.

ArgumentNullException

sleepDurationProvider or onRetryAsync

WaitAndRetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<int, Context, TimeSpan>)

Builds a Policy that will wait and retry indefinitely until the action succeeds.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurationProvider Func<int, Context, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurationProvider

WaitAndRetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<int, Context, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan, Context>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurationProvider Func<int, Context, TimeSpan>

A function providing the duration to wait before retrying.

onRetry Action<DelegateResult<TResult>, TimeSpan, Context>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurationProvider

ArgumentNullException

onRetry

WaitAndRetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<int, Context, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Context, Task>)

Builds a Policy that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result and execution context.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurationProvider Func<int, Context, TimeSpan>

A function providing the duration to wait before retrying.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Context, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurationProvider

ArgumentNullException

onRetryAsync

WaitAndRetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<int, TimeSpan>)

Builds a Policy that will wait and retry indefinitely until the action succeeds.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurationProvider Func<int, TimeSpan>

The function that provides the duration to wait for for a particular retry attempt.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurationProvider

WaitAndRetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<int, TimeSpan>, Action<DelegateResult<TResult>, TimeSpan>)

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

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurationProvider Func<int, TimeSpan>

A function providing the duration to wait before retrying.

onRetry Action<DelegateResult<TResult>, TimeSpan>

The action to call on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurationProvider

ArgumentNullException

onRetry

WaitAndRetryForeverAsync<TResult>(PolicyBuilder<TResult>, Func<int, TimeSpan>, Func<DelegateResult<TResult>, TimeSpan, Task>)

Builds a Policy that will wait and retry indefinitely until the action succeeds, calling onRetryAsync on each retry with the handled exception or result.

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

Parameters

policyBuilder PolicyBuilder<TResult>

The policy builder.

sleepDurationProvider Func<int, TimeSpan>

A function providing the duration to wait before retrying.

onRetryAsync Func<DelegateResult<TResult>, TimeSpan, Task>

The action to call asynchronously on each retry.

Returns

RetryPolicy<TResult>

The policy instance.

Type Parameters

TResult

Exceptions

ArgumentNullException

sleepDurationProvider

ArgumentNullException

onRetryAsync