protected override TimeSpan?OnGetNextRetryInterval(string clientId, Exception lastException, TimeSpan remainingTime, int baseWaitTimeSecs)
        {
            int currentRetryCount = this.GetRetryCount(clientId);

            if (currentRetryCount >= this.maximumRetryCount)
            {
                return(null);
            }

            if (!RetryPolicy.IsRetryableException(lastException))
            {
                return(null);
            }

            double nextRetryInterval             = Math.Pow(this.retryFactor, (double)currentRetryCount);
            long   nextRetryIntervalSeconds      = (long)nextRetryInterval;
            long   nextRetryIntervalMilliseconds = (long)((nextRetryInterval - (double)nextRetryIntervalSeconds) * 1000);

            if (remainingTime.TotalSeconds < Math.Max(nextRetryInterval, ClientConstants.TimerToleranceInSeconds))
            {
                return(null);
            }

            TimeSpan retryAfter = this.minimumBackoff.Add(TimeSpan.FromMilliseconds(nextRetryIntervalSeconds * 1000 + nextRetryIntervalMilliseconds));

            retryAfter = retryAfter.Add(TimeSpan.FromSeconds(baseWaitTimeSecs));

            return(retryAfter);
        }
        /// <summary></summary>
        /// <param name="lastException"></param>
        /// <param name="remainingTime"></param>
        /// <param name="baseWaitTimeSecs"></param>
        /// <param name="retryCount"></param>
        /// <returns></returns>
        protected override TimeSpan?OnGetNextRetryInterval(Exception lastException, TimeSpan remainingTime, int baseWaitTimeSecs, int retryCount)
        {
            if (retryCount >= this.maximumRetryCount)
            {
                return(null);
            }

            if (!RetryPolicy.IsRetryableException(lastException))
            {
                return(null);
            }

            double nextRetryInterval             = Math.Pow(this.retryFactor, (double)retryCount);
            long   nextRetryIntervalSeconds      = (long)nextRetryInterval;
            long   nextRetryIntervalMilliseconds = (long)((nextRetryInterval - (double)nextRetryIntervalSeconds) * 1000);

            TimeSpan retryAfter = this.minimumBackoff.Add(TimeSpan.FromMilliseconds(nextRetryIntervalSeconds * 1000 + nextRetryIntervalMilliseconds));

            retryAfter = retryAfter.Add(TimeSpan.FromSeconds(baseWaitTimeSecs));

            return(retryAfter);
        }