# Class ExponentialBackOff (1.73.0)

<button class="button button-with-icon cloud-select-dropdown__button " aria-haspopup="true">Version latest</button>

- [1.73.0 (latest)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff)
- [1.69.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.69.0/Google.Apis.Util.ExponentialBackOff)
- [1.68.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.68.0/Google.Apis.Util.ExponentialBackOff)
- [1.60.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.60.0/Google.Apis.Util.ExponentialBackOff)
- [1.59.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.59.0/Google.Apis.Util.ExponentialBackOff)
- [1.55.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.55.0/Google.Apis.Util.ExponentialBackOff)
- [1.50.0](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/1.50.0/Google.Apis.Util.ExponentialBackOff)

    public class ExponentialBackOff : IBackOff

Implementation of [IBackOff](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.IBackOff) that increases the back-off period for each retry attempt using a
randomization function that grows exponentially. In addition, it also adds a randomize number of milliseconds
for each attempt.

## Inheritance

[object](https://learn.microsoft.com/dotnet/api/system.object) \> ExponentialBackOff

## Implements

[IBackOff](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.IBackOff)

## Inherited Members

[object.Equals(object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)) [object.Equals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)) [object.GetHashCode()](https://learn.microsoft.com/dotnet/api/system.object.gethashcode) [object.GetType()](https://learn.microsoft.com/dotnet/api/system.object.gettype) [object.MemberwiseClone()](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone) [object.ReferenceEquals(object, object)](https://learn.microsoft.com/dotnet/api/system.object.referenceequals) [object.ToString()](https://learn.microsoft.com/dotnet/api/system.object.tostring)

## Namespace

[Google.Apis.Util](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util)

## Assembly

Google.Apis.Core.dll

## Constructors

### ExponentialBackOff()

    public ExponentialBackOff()

Constructs a new exponential back-off with [DeltaBackOff](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff#Google_Apis_Util_ExponentialBackOff_DeltaBackOff) set to 250ms
and [MaxNumOfRetries](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff#Google_Apis_Util_ExponentialBackOff_MaxNumOfRetries) set to 10.

### ExponentialBackOff(TimeSpan, int)

    public ExponentialBackOff(TimeSpan deltaBackOff, int maximumNumOfRetries = 10)

Constructs a new exponential back-off with the given delta and maximum retries.
If unspecified, `maximumNumOfRetries` is set to 10.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `deltaBackOff` | `https://learn.microsoft.com/dotnet/api/system.timespan` |
| `maximumNumOfRetries` | `https://learn.microsoft.com/dotnet/api/system.int32` |

## Properties

### DeltaBackOff

    public TimeSpan DeltaBackOff { get; }

Time span used to bound the back-off jitter.
If the value is [Zero](https://learn.microsoft.com/dotnet/api/system.timespan.zero) then the generated back-off will be exactly 1, 2, 4,
8, 16, etc. seconds. A valid value is between zero and one second. The default value is 250ms, which means
that the generated back-off will be between 0.75sec and 1.25sec, 1.75sec and 2.25sec, 3.75sec and 4.25sec, and so on.
Only one of [DeltaBackOff](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff#Google_Apis_Util_ExponentialBackOff_DeltaBackOff) and [DeltaBackOffPercent](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff#Google_Apis_Util_ExponentialBackOff_DeltaBackOffPercent) may be specified. Both may be zero,
in which case no jitter will be applied.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.timespan` |   |

### DeltaBackOffPercent

    public short DeltaBackOffPercent { get; }

Percent of the current unjittered back-off used to bound the jitter.
If the value is set to 10, and the current back-off is 1000ms, then the jitter will be generated
from -100ms to 100ms and the jittered back-off will be from 900ms to 1100ms.
Only one of [DeltaBackOff](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff#Google_Apis_Util_ExponentialBackOff_DeltaBackOff) and [DeltaBackOffPercent](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff#Google_Apis_Util_ExponentialBackOff_DeltaBackOffPercent) may be specified. Both may be zero,
in which case no jitter will be applied.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int16` |   |

### MaxNumOfRetries

    public int MaxNumOfRetries { get; }

The maximum number of retries. Default value is `10`.

| **Property Value** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.int32` |   |

## Methods

### FromDeltaBackOffPercent(short, int)

    public static ExponentialBackOff FromDeltaBackOffPercent(short deltaBackOffPercent, int maximumNumOfRetries = 10)

Constructs a new exponential back-off with the given delta percent and maximum retries.
If unspecified, `maximumNumOfRetries` is set to 10.

| **Parameters** ||
|---|---|
| **Name** | **Description** |
| `deltaBackOffPercent` | `https://learn.microsoft.com/dotnet/api/system.int16` |
| `maximumNumOfRetries` | `https://learn.microsoft.com/dotnet/api/system.int32` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.ExponentialBackOff` |   |

### GetNextBackOff(int)

    public TimeSpan GetNextBackOff(int currentRetry)

Gets the a time span to wait before next retry. If the current retry reached the maximum number of retries,
the returned value is [MinValue](https://learn.microsoft.com/dotnet/api/system.timespan.minvalue).

| **Parameter** ||
|---|---|
| **Name** | **Description** |
| `currentRetry` | `https://learn.microsoft.com/dotnet/api/system.int32` |

| **Returns** ||
|---|---|
| **Type** | **Description** |
| `https://learn.microsoft.com/dotnet/api/system.timespan` |   |

## Extension Method

[Utilities.ThrowIfNull\<T\>(T, string)](https://docs.cloud.google.com/dotnet/docs/reference/Google.Apis/latest/Google.Apis.Util.Utilities#Google_Apis_Util_Utilities_ThrowIfNull__1___0_System_String_)