Class RetrySyntaxAsync
- Namespace
- Polly
- Assembly
- Polly.dll
Fluent API for defining a Retry Policy.
public static class RetrySyntaxAsync
- Inheritance
-
RetrySyntaxAsync
- Inherited Members
Methods
RetryAsync(PolicyBuilder)
Builds a Policy that will retry once.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder)
Parameters
policyBuilderPolicyBuilderThe policy builder.
Returns
- RetryPolicy
The policy instance.
RetryAsync(PolicyBuilder, Action<Exception, int, Context>)
Builds a Policy that will retry once
calling onRetry on retry with the raised exception, retry count and context data.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Action<Exception, int, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAction<Exception, int, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetry
RetryAsync(PolicyBuilder, Action<Exception, int>)
Builds a Policy that will retry once
calling onRetry on retry with the raised exception and retry count.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Action<Exception, int> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAction<Exception, int>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetry
RetryAsync(PolicyBuilder, Func<Exception, int, Context, Task>)
Builds a Policy that will retry once
calling onRetryAsync on retry with the raised exception, retry count and context data.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Func<Exception, int, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAsyncFunc<Exception, int, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetry
RetryAsync(PolicyBuilder, Func<Exception, int, Task>)
Builds a Policy that will retry once
calling onRetryAsync on retry with the raised exception and retry count.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Func<Exception, int, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAsyncFunc<Exception, int, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetry
RetryAsync(PolicyBuilder, int)
Builds a Policy that will retry retryCount times.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
Returns
- RetryPolicy
The policy instance.
RetryAsync(PolicyBuilder, int, Action<Exception, int, Context>)
Builds a Policy that will retry retryCount times
calling onRetry on each retry with the raised exception, retry count and context data.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action<Exception, int, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
onRetryAction<Exception, int, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than zero.
- ArgumentNullException
onRetry
RetryAsync(PolicyBuilder, int, Action<Exception, int>)
Builds a Policy that will retry retryCount times
calling onRetry on each retry with the raised exception and retry count.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action<Exception, int> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
onRetryAction<Exception, int>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
onRetry
RetryAsync(PolicyBuilder, int, Func<Exception, int, Context, Task>)
Builds a Policy that will retry retryCount times
calling onRetryAsync on each retry with the raised exception, retry count and context data.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<Exception, int, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
onRetryAsyncFunc<Exception, int, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than zero.
- ArgumentNullException
onRetryAsync
RetryAsync(PolicyBuilder, int, Func<Exception, int, Task>)
Builds a Policy that will retry retryCount times
calling onRetryAsync on each retry with the raised exception and retry count.
public static RetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<Exception, int, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
onRetryAsyncFunc<Exception, int, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
onRetryAsync
RetryForeverAsync(PolicyBuilder)
Builds a Policy that will retry indefinitely until the action succeeds.
public static RetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder)
Parameters
policyBuilderPolicyBuilderThe policy builder.
Returns
- RetryPolicy
The policy instance.
RetryForeverAsync(PolicyBuilder, Action<Exception, Context>)
Builds a Policy that will retry indefinitely
calling onRetry on each retry with the raised exception and context data.
public static RetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action<Exception, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAction<Exception, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetry
RetryForeverAsync(PolicyBuilder, Action<Exception>)
Builds a Policy that will retry indefinitely
calling onRetry on each retry with the raised exception.
public static RetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action<Exception> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAction<Exception>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetry
RetryForeverAsync(PolicyBuilder, Func<Exception, Context, Task>)
Builds a Policy that will retry indefinitely
calling onRetryAsync on each retry with the raised exception and context data.
public static RetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func<Exception, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAsyncFunc<Exception, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetryAsync
RetryForeverAsync(PolicyBuilder, Func<Exception, Task>)
Builds a Policy that will retry indefinitely
calling onRetryAsync on each retry with the raised exception.
public static RetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func<Exception, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
onRetryAsyncFunc<Exception, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
onRetryAsync
WaitAndRetryAsync(PolicyBuilder, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
Returns
- RetryPolicy
The policy instance.
WaitAndRetryAsync(PolicyBuilder, IEnumerable<TimeSpan>, Action<Exception, 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 raised exception, the current sleep duration and context data.
On each retry, the duration to wait is the current sleepDurations item.
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<Exception, TimeSpan, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetryAction<Exception, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurations or onRetry
WaitAndRetryAsync(PolicyBuilder, IEnumerable<TimeSpan>, Action<Exception, 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 raised exception, the current sleep duration, retry count, and context data.
On each retry, the duration to wait is the current sleepDurations item.
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<Exception, TimeSpan, int, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetryAction<Exception, TimeSpan, int, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurations or onRetry
WaitAndRetryAsync(PolicyBuilder, IEnumerable<TimeSpan>, Action<Exception, TimeSpan>)
Builds a Policy that will wait and retry as many times as there are provided
sleepDurations
calling onRetry on each retry with the raised exception and the current sleep duration.
On each retry, the duration to wait is the current sleepDurations item.
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<Exception, TimeSpan> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetryAction<Exception, TimeSpan>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurations or onRetry
WaitAndRetryAsync(PolicyBuilder, IEnumerable<TimeSpan>, Func<Exception, 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 raised exception, the current sleep duration and context data.
On each retry, the duration to wait is the current sleepDurations item.
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetryAsyncFunc<Exception, TimeSpan, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurations or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, IEnumerable<TimeSpan>, Func<Exception, 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 raised exception, the current sleep duration, retry count, and context data.
On each retry, the duration to wait is the current sleepDurations item.
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetryAsyncFunc<Exception, TimeSpan, int, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurations or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, IEnumerable<TimeSpan>, Func<Exception, 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 raised exception and the current sleep duration.
On each retry, the duration to wait is the current sleepDurations item.
public static RetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<Exception, TimeSpan, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationsIEnumerable<TimeSpan>The sleep durations to wait for on each retry.
onRetryAsyncFunc<Exception, TimeSpan, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurations or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, int, Func<int, Context, TimeSpan>, Action<Exception, TimeSpan, Context>)
Builds a Policy that will wait and retry retryCount times
calling onRetry on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAction<Exception, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetryAsync(PolicyBuilder, int, Func<int, Context, TimeSpan>, Action<Exception, TimeSpan, int, Context>)
Builds a Policy that will wait and retry retryCount times
calling onRetry on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, int, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAction<Exception, TimeSpan, int, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetryAsync(PolicyBuilder, int, Func<int, Context, TimeSpan>, Func<Exception, TimeSpan, Context, Task>)
Builds a Policy that will wait and retry retryCount times
calling onRetryAsync on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAsyncFunc<Exception, TimeSpan, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, int, Func<int, Context, TimeSpan>, Func<Exception, TimeSpan, int, Context, Task>)
Builds a Policy that will wait and retry retryCount times
calling onRetryAsync on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAsyncFunc<Exception, TimeSpan, int, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy
The policy instance.
WaitAndRetryAsync(PolicyBuilder, int, Func<int, TimeSpan>, Action<Exception, TimeSpan, Context>)
Builds a Policy that will wait and retry retryCount times
calling onRetry on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAction<Exception, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetryAsync(PolicyBuilder, int, Func<int, TimeSpan>, Action<Exception, TimeSpan, int, Context>)
Builds a Policy that will wait and retry retryCount times
calling onRetry on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, int, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAction<Exception, TimeSpan, int, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetryAsync(PolicyBuilder, int, Func<int, TimeSpan>, Action<Exception, TimeSpan>)
Builds a Policy that will wait and retry retryCount times
calling onRetry on each retry with the raised exception 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAction<Exception, TimeSpan>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetry
WaitAndRetryAsync(PolicyBuilder, int, Func<int, TimeSpan>, Func<Exception, TimeSpan, Context, Task>)
Builds a Policy that will wait and retry retryCount times
calling onRetryAsync on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAsyncFunc<Exception, TimeSpan, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, int, Func<int, TimeSpan>, Func<Exception, TimeSpan, int, Context, Task>)
Builds a Policy that will wait and retry retryCount times
calling onRetryAsync on each retry with the raised exception, 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAsyncFunc<Exception, TimeSpan, int, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetryAsync
WaitAndRetryAsync(PolicyBuilder, int, Func<int, TimeSpan>, Func<Exception, TimeSpan, Task>)
Builds a Policy that will wait and retry retryCount times
calling onRetryAsync on each retry with the raised exception 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 WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
retryCountintThe retry count.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
onRetryAsyncFunc<Exception, TimeSpan, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentOutOfRangeException
retryCount;Value must be greater than or equal to zero.
- ArgumentNullException
sleepDurationProvider or onRetryAsync
WaitAndRetryForeverAsync(PolicyBuilder, Func<int, Context, TimeSpan>)
Builds a Policy that will wait and retry indefinitely until the action succeeds.
public static RetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationProviderFunc<int, Context, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurationProvider
WaitAndRetryForeverAsync(PolicyBuilder, Func<int, Context, TimeSpan>, Action<Exception, TimeSpan, Context>)
Builds a Policy that will wait and retry indefinitely
calling onRetry on each retry with the raised exception and
execution context.
public static RetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, Context> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationProviderFunc<int, Context, TimeSpan>A function providing the duration to wait before retrying.
onRetryAction<Exception, TimeSpan, Context>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurationProvider
- ArgumentNullException
onRetry
WaitAndRetryForeverAsync(PolicyBuilder, Func<int, Context, TimeSpan>, Func<Exception, TimeSpan, Context, Task>)
Builds a Policy that will wait and retry indefinitely
calling onRetryAsync on each retry with the raised exception and
execution context.
public static RetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationProviderFunc<int, Context, TimeSpan>A function providing the duration to wait before retrying.
onRetryAsyncFunc<Exception, TimeSpan, Context, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurationProvider
- ArgumentNullException
onRetryAsync
WaitAndRetryForeverAsync(PolicyBuilder, Func<int, TimeSpan>)
Builds a Policy that will wait and retry indefinitely until the action succeeds.
public static RetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationProviderFunc<int, TimeSpan>The function that provides the duration to wait for for a particular retry attempt.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurationProvider
WaitAndRetryForeverAsync(PolicyBuilder, Func<int, TimeSpan>, Action<Exception, TimeSpan>)
Builds a Policy that will wait and retry indefinitely
calling onRetry on each retry with the raised exception.
public static RetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan> onRetry)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationProviderFunc<int, TimeSpan>A function providing the duration to wait before retrying.
onRetryAction<Exception, TimeSpan>The action to call on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurationProvider
- ArgumentNullException
onRetry
WaitAndRetryForeverAsync(PolicyBuilder, Func<int, TimeSpan>, Func<Exception, TimeSpan, Task>)
Builds a Policy that will wait and retry indefinitely
calling onRetryAsync on each retry with the raised exception.
public static RetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Task> onRetryAsync)
Parameters
policyBuilderPolicyBuilderThe policy builder.
sleepDurationProviderFunc<int, TimeSpan>A function providing the duration to wait before retrying.
onRetryAsyncFunc<Exception, TimeSpan, Task>The action to call asynchronously on each retry.
Returns
- RetryPolicy
The policy instance.
Exceptions
- ArgumentNullException
sleepDurationProvider
- ArgumentNullException
onRetryAsync