<PackageReference Include="Azure.Core" Version="1.44.1" />

DelayStrategy

public abstract class DelayStrategy
An abstraction to control delay behavior.
protected DelayStrategy(TimeSpan? maxDelay = default, double jitterFactor = 0.2)

Constructs a new instance of DelayStrategy. This constructor can be used by derived classes to customize the jitter factor and max delay.

public static DelayStrategy CreateExponentialDelayStrategy(TimeSpan? initialDelay = default, TimeSpan? maxDelay = default)

Constructs an exponential delay with jitter.

public static DelayStrategy CreateFixedDelayStrategy(TimeSpan? delay = default)

Constructs a fixed delay with jitter.

protected static TimeSpan Max(TimeSpan val1, TimeSpan val2)

Gets the maximum of two TimeSpan values.

protected static TimeSpan Min(TimeSpan val1, TimeSpan val2)

Gets the minimum of two TimeSpan values.

public TimeSpan GetNextDelay(Response response, int retryNumber)

Gets the next delay interval taking into account the Max Delay, jitter, and any Retry-After headers.

protected abstract TimeSpan GetNextDelayCore(Response response, int retryNumber)

Gets the next delay interval. Implement this method to provide custom delay logic. The Max Delay, jitter, and any Retry-After headers will be applied to the value returned from this method.