Table of Contents

Method DelayBeforeNextAttempt

Namespace
MailFathom.Application.Resilience
Assembly
MailFathom.Application.dll

DelayBeforeNextAttempt(TimeSpan, TimeSpan, TimeSpan, int)

Computes how long the work waits before its next attempt.

public static TimeSpan DelayBeforeNextAttempt(TimeSpan baseDelay, TimeSpan maxDelay, TimeSpan minimumDelay, int attemptCount)

Parameters

baseDelay TimeSpan

The delay the first retry is drawn around, from which the doubling grows.

maxDelay TimeSpan

The ceiling a grown delay never exceeds.

minimumDelay TimeSpan

The delay no draw falls below, which is Zero for work that has no wait of its own to respect.

attemptCount int

How many attempts the work has already been handed out for, counting from one.

Returns

TimeSpan

A jittered delay of at least half the grown ceiling, never below minimumDelay, and at most maxDelay.

Remarks

The floor is bounded by the base delay rather than by the ceiling, because a floor above the range the first attempt draws from is a caller stating two delays that contradict each other rather than one curve with a lower bound.

Exceptions

ArgumentOutOfRangeException

Thrown when baseDelay is not positive, when maxDelay is below it, when minimumDelay is negative or above baseDelay, or when attemptCount is not positive.