public void Execute() { var exceptions = new List <Exception>(); int tries = 0; int sleepMSec = 500; while (tries <= MaxRetries) { tries++; try { Operation(); break; } catch (T e) { exceptions.Add(e); if (tries > MaxRetries) { throw new AggregateException("Operation failed after maximum number of retries were exceeded.", exceptions); } } Logger.WriteInfo(string.Format("Operation failed, retrying in {0} milliseconds.", sleepMSec)); ThreadSleep.Sleep(sleepMSec); sleepMSec *= 2; } }
public void SomeMethod() { // _threadSleep.Sleep(100); }