Class ExponentialBackoff
Tracks consecutive failures and gates retries behind an exponential backoff window: baseDelay, 2×baseDelay, 4×baseDelay ... capped at maxDelay. The window grows on each failure and clears on success/reset. Not thread-safe; callers sharing an instance must synchronize.
public class ExponentialBackoff
- Inheritance
-
ExponentialBackoff
- Inherited Members
Constructors
ExponentialBackoff(TimeSpan, TimeSpan)
Tracks consecutive failures and gates retries behind an exponential backoff window: baseDelay, 2×baseDelay, 4×baseDelay ... capped at maxDelay. The window grows on each failure and clears on success/reset. Not thread-safe; callers sharing an instance must synchronize.
public ExponentialBackoff(TimeSpan baseDelay, TimeSpan maxDelay)
Parameters
Properties
CurrentDelay
The current backoff delay for the consecutive failure count (Zero when there are no failures).
public TimeSpan CurrentDelay { get; }
Property Value
FailCount
Number of consecutive failures since the last reset.
public int FailCount { get; }
Property Value
IsReady
True when there is no pending failure or the backoff window has elapsed since the last failure.
public bool IsReady { get; }
Property Value
Methods
OnFail()
Records a failed attempt, growing the backoff window.
public void OnFail()
Reset()
Clears the failure history so the next attempt is allowed immediately.
public void Reset()