Export (0) Print
Expand All

RetryPolicies.RetryExponential Method (Int32, TimeSpan, TimeSpan, TimeSpan)

Updated: April 24, 2013

[This topic is part of the Microsoft Azure Storage Client Library 1.7, which has been deprecated. See Storage Client Library for the latest version.]

Returns a policy that retries a specified number of times with a randomized exponential backoff scheme, using specified minimum and maximum backoff values.

Namespace: Microsoft.WindowsAzure.StorageClient
Assembly: Microsoft.WindowsAzure.StorageClient (in Microsoft.WindowsAzure.StorageClient.dll)

Dim retryCount As Integer
Dim minBackoff As TimeSpan
Dim maxBackoff As TimeSpan
Dim deltaBackoff As TimeSpan
Dim returnValue As RetryPolicy

returnValue = RetryPolicies.RetryExponential(retryCount, minBackoff, maxBackoff, deltaBackoff)

public static RetryPolicy RetryExponential (
	int retryCount,
	TimeSpan minBackoff,
	TimeSpan maxBackoff,
	TimeSpan deltaBackoff



Type: System.Int32

A non-negative number indicating the number of times to retry.


Type: System.TimeSpan

The minimum backoff interval.


Type: System.TimeSpan

The maximum backoff interval.


Type: System.TimeSpan

The delta backoff value used by the exponential backoff retry policy.

Return Value

Type: Microsoft.WindowsAzure.StorageClient.RetryPolicy

The retry policy.

The retry policy returned by RetryExponential performs an exponential backoff determined by the values of minBackoff, maxBackoff, and deltaBackoff.

The RetryExponential method returns a delegate that uses the algorithm shown here:

public static RetryPolicy RetryExponential(int retryCount, TimeSpan minBackoff, TimeSpan maxBackoff, TimeSpan deltaBackoff)
    return () =>
        return (int currentRetryCount, Exception lastException, out TimeSpan retryInterval) =>
            if (currentRetryCount < retryCount)
                Random rand = new Random();
                int increment = (int)((Math.Pow(2, currentRetryCount) - 1) * rand.Next((int)(deltaBackoff.TotalMilliseconds * 0.8), (int)(deltaBackoff.TotalMilliseconds * 1.2)));
                int timeToSleepMsec = (int)Math.Min(minBackoff.TotalMilliseconds + increment, maxBackoff.TotalMilliseconds);

                retryInterval = TimeSpan.FromMilliseconds(timeToSleepMsec);

                return true;

            retryInterval = TimeSpan.Zero;
            return false;

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Development Platforms

Windows Vista, Windows 7, Windows Server 2008, Windows 8.1, Windows Server 2012 R2, Windows 8 and Windows Server 2012


© 2014 Microsoft