protected void TryFiveTimes(IRepeatableOperation repeatableOperation) { int counter = 0; while (counter < 5) { try { repeatableOperation.Execute(Log); break; } catch (Exception) { Log.Debug("Operation {0} failed {1}. time", repeatableOperation.Name, counter + 1); if (counter == 4) throw; else System.Threading.Thread.Sleep(100 + counter * 200); } counter++; } }
protected void TryFiveTimes(IRepeatableOperation repeatableOperation) { int counter = 0; while (counter < 5) { try { repeatableOperation.Execute(Log); break; } catch (Exception) { Log.Debug("Operation {0} failed {1}. time", repeatableOperation.Name, counter + 1); if (counter == 4) { throw; } else { System.Threading.Thread.Sleep(100 + counter * 200); } } counter++; } }