Example #1
0
 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));
 }
Example #2
0
 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);
 }
Example #3
0
 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) });
 }
Example #4
0
 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);
 }
Example #5
0
 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));
 }