Language

TaskRetryPolicy Class

Definition

Controls how a failed task handler is retried: the maximum number of attempts, the delay between attempts, and an optional predicate selecting which exceptions are retryable. The delay is expressed as an DelayStrategy so fixed, exponential, jittered, and custom-derived backoff all use one delay model instead of a second bespoke one.

public sealed class TaskRetryPolicy
type TaskRetryPolicy = class
Public NotInheritable Class TaskRetryPolicy
Inheritance
TaskRetryPolicy

Constructors

Name Description
TaskRetryPolicy()

Properties

Name Description
Delay

The delay strategy applied between attempts. Defaults to an exponential strategy. Use CreateExponentialDelayStrategy(Nullable<TimeSpan>, Nullable<TimeSpan>), CreateFixedDelayStrategy(Nullable<TimeSpan>), or a custom derived strategy for linear or service-specific behavior. The strategy owns its own jitter and maximum-delay handling.

MaxAttempts

The maximum number of attempts, including the first. Defaults to 3. Must be between 1 and the hard cap of 10; a larger or non-positive value throws ArgumentOutOfRangeException. Set to 1 to disable retries.

RetryOn

An optional predicate deciding whether a given exception is retryable; null retries all.

Applies to