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 async Task RetryAsyncWithReturn() { // Execute the DoWorkAsync int i = await Retry.ExecuteAsync(async() => { return(await DummyMethods.DoWorkAsyncAndReturn()); }, TimeSpan.FromMilliseconds(100), 2); }
public async Task RetryAsync() { // Execute the DoWorkAsync await Retry.ExecuteAsync(async() => { await DummyMethods.DoWorkAsync(); }, TimeSpan.FromMilliseconds(100), 2); }
public async Task RetryAsyncWithAllFeatures() { // Execute the DoWorkAsync await Retry.ExecuteAsync(async() => await DummyMethods.DoWorkAsync(), TimeSpan.FromMilliseconds(100), 2, DummyMethods.ExecuteOnExceptionAsync, DummyMethods.ExecuteOnExceptionAsync, typeof(ArgumentException)); }
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 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 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 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)); }