Skip to main content
The retry strategy enables configurable retry behavior with support for exponential backoff, jitter, and custom retry predicates.

RetryStrategyOptions

Configures the retry resilience strategy.

Properties

int
default:"3"
The maximum number of retries to use, in addition to the original call.
  • Must be between 1 and int.MaxValue
  • Use int.MaxValue to retry indefinitely
DelayBackoffType
default:"Constant"
The type of back-off strategy to use between retries.Supported values:
  • Constant: Fixed delay between retries
  • Linear: Delay increases linearly
  • Exponential: Delay increases exponentially
This property is ignored when DelayGenerator is set.
bool
default:"false"
Indicates whether jitter should be used when calculating the backoff delay.Jitter helps prevent correlated retries and can improve overall resilience.
TimeSpan
default:"00:00:02"
The base delay between retries.
  • For Exponential: Represents the median delay before the first retry
  • For Linear: Represents the initial delay, increasing linearly
  • For Constant: Represents the fixed delay between retries
This property is ignored when DelayGenerator returns a valid TimeSpan.
TimeSpan?
default:"null"
The maximum delay between retries.Used to cap the maximum delay, especially useful with exponential backoff. If null, the delay is not capped.
Func<RetryPredicateArguments<TResult>, ValueTask<bool>>
required
A predicate that determines whether the retry should be executed for a given outcome.Default: Retries on any exception except OperationCanceledException.
Func<RetryDelayGeneratorArguments<TResult>, ValueTask<TimeSpan?>>?
default:"null"
A generator that calculates the delay between retries.If the generator returns null, the delay calculated by the retry strategy will be used.
Func<OnRetryArguments<TResult>, ValueTask>?
default:"null"
An event delegate that is raised when a retry happens.Important: After this event, the result is discarded and disposed. Create a copy if you need to preserve it.

Extension Methods

Add retry strategies to a resilience pipeline using these extension methods:

OnRetryArguments

Arguments passed to the OnRetry callback.

Usage Example