public TimeSpan Retry(TimeSpan?resetTimer = null) { DisposeTimer(_resetTimer); if (resetTimer != null) { TimedReset(resetTimer.Value); } var span = ExponentialBackoff(Interlocked.Increment(ref _tryCount)); DisposeTimer(_retryTimer); _retryTimer = new Timer(span.TotalMilliseconds); _retryTimer.Elapsed += (_, __) => { RetryHandler?.Invoke(this, EventArgs.Empty); _retryHandler?.Invoke(); _asyncRetryHandler?.Invoke(); DisposeTimer(_retryTimer); }; _retryTimer.Start(); return(span); }