Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

RetryPolicies.RetryExponential Method (Int32, TimeSpan)

Updated: April 24, 2013

[This topic is part of the Windows Azure Storage Client Library 1.7, which has been deprecated. The current recommended version is Storage Client Library 3.0.]

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

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

public static RetryPolicy RetryExponential (
	int retryCount,
	TimeSpan deltaBackoff



Type: System.Int32

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


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 using default values for the minimum backoff and the maximum backoff. The default values are defined by the DefaultMinBackoff and DefaultMaxBackoff constants.

This method provides the default retry policy for the CloudBlobClient, CloudQueueClient, and CloudTableClient objects. The default retry policy for the service client objects is set by calling RetryExponential to return a retry policy delegate that passes the DefaultClientRetryCount to specify the number of times to retry, and the DefaultClientBackoff constant to calculate the increment for the backoff interval.

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

public static RetryPolicy RetryExponential(int retryCount, TimeSpan deltaBackoff)
    //Returns a RetryPolicy delegate.
    return () =>
        //Returns a ShouldRetry delegate.
        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(RetryPolicies.DefaultMinBackoff.TotalMilliseconds + increment, RetryPolicies.DefaultMaxBackoff.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 and Windows Server 2008

Target Platforms

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
© 2014 Microsoft. All rights reserved.