Table of Contents

Class ExponentialBackoff

Namespace
VpnHood.Net.Toolkit.Utils
Assembly
VpnHood.Net.Toolkit.dll

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

baseDelay TimeSpan
maxDelay TimeSpan

Properties

CurrentDelay

The current backoff delay for the consecutive failure count (Zero when there are no failures).

public TimeSpan CurrentDelay { get; }

Property Value

TimeSpan

FailCount

Number of consecutive failures since the last reset.

public int FailCount { get; }

Property Value

int

IsReady

True when there is no pending failure or the backoff window has elapsed since the last failure.

public bool IsReady { get; }

Property Value

bool

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()