Ejemplo n.º 1
0
        async Task AttemptRestart(IRestartable restartable, int attempt, Exception error)
        {
            attempt += 1;

            // quite if there are no more delays in the sequence
            if (!_delays.MoveNext())
            {
                await restartable.MaxRestartsReached(attempt);

                return;
            }

            // attempt another restart
            TimeSpan delay = _delays.Current;

            Debug.Assert(delay > TimeSpan.Zero);
            await restartable.PauseBeforeRestart(delay);

            try
            {
                await restartable.Restart();
            }
            catch (Exception ex)
            {
                Logging.Log.Warning("Failed to restart: " + ex);
                return;
            }
            Monitor(restartable, attempt);
        }