AK.F1.Timing.Utility.Recorder.Program.DoIOBoundOperation C# (CSharp) Method

DoIOBoundOperation() private static method

private static DoIOBoundOperation ( System.Action operation ) : void
operation System.Action
return void
        private static void DoIOBoundOperation(Action operation)
        {
            int attempt = 1;
            const int maxAttempts = 6;
            TimeSpan backoff = TimeSpan.FromSeconds(5D);

            while(attempt <= maxAttempts)
            {
                try
                {
                    operation();
                    break;
                }
                catch(IOException exc)
                {
                    Log.Error(exc);
                }
                ++attempt;
                Log.InfoFormat("backing off for {0}s before attempt {1}/{2}",
                    backoff.TotalSeconds, attempt, maxAttempts);
                Thread.Sleep(backoff);
                backoff += backoff;
            }
        }