public override bool TryNextInterval(out TimeSpan intervalTime) { intervalTime = TimeSpan.Zero; // First try has occurred before starting the retry process. // Check if retry is still allowed bool result = Current < NumberOfTries - 1; if (result) { // Increase the number of attempts Current++; // It's okay if the RetryIntervalEnumerator gets to the last value before we've reached our maximum number of attempts. // MoveNext() will simply leave the enumerator on the final interval value and we will repeat that for the final attempts. RetryIntervalEnumerator.MoveNext(); // Receive the current time from enumerator intervalTime = RetryIntervalEnumerator.Current; } return(result); }
public override bool TryNextInterval(out TimeSpan intervalTime) { intervalTime = TimeSpan.Zero; // First try has occurred before starting the retry process. bool result = Current < NumberOfTries - 1; if (result) { Current++; // it doesn't mind if the enumerator gets to the last value till the number of attempts ends. RetryIntervalEnumerator.MoveNext(); intervalTime = RetryIntervalEnumerator.Current; SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> Next gap time will be '{2}' before the next retry number {3}", TypeName, MethodBase.GetCurrentMethod().Name, intervalTime, Current); } else { SqlClientEventSource.Log.TryTraceEvent("<sc.{0}.{1}|INFO> Current retry ({2}) has reached the maximum attempts (total attempts excluding the first run = {3}).", TypeName, MethodBase.GetCurrentMethod().Name, Current, NumberOfTries - 1); } return(result); }