public void AllFeatures() { // All retry features in one method: Retry.Execute(() => DummyMethods.DoWork("Hello world"), TimeSpan.FromMilliseconds(100), 2, DummyMethods.ExecuteOnEveryException, DummyMethods.ExecuteWhenMaxRetriesReachedBeforeExceptionIsThrown, typeof(ArgumentException), typeof(DbException)); }
public void ExecuteMethodBeforeFinalExceptionIsThrown() { // Execute the DoWork and only Execute a method before the final AggregateException is thrown Retry.Execute(() => DummyMethods.DoWork("Hello world"), TimeSpan.FromMilliseconds(100), 2, executeBeforeFinalException: DummyMethods.ExecuteWhenMaxRetriesReachedBeforeExceptionIsThrown); }
public void RetryOnlySpecificExceptions() { // Execute the DoWork and only retry with an exception that is of (base)type DbException Retry.Execute(() => DummyMethods.DoWork("Hello world"), TimeSpan.FromMilliseconds(100), 2, exceptionTypesToHandle: new[] { typeof(ArgumentException), typeof(ArgumentOutOfRangeException) }); }
public void ExecuteMethodOnEachException() { // Execute the DoWork and only Execute a method after each exception is thrown. Retry.Execute(() => DummyMethods.DoWork("Hello world"), TimeSpan.FromMilliseconds(100), 2, executeOnEveryException: DummyMethods.ExecuteOnEveryException); }
public void RetryOnlySpecificException() { // Execute the DoWork and only retry with an exception that is of (base)type DbException Retry.Execute(() => DummyMethods.DoWork("Hello world"), TimeSpan.FromMilliseconds(100), 2, exceptionTypesToHandle: typeof(DbException)); }