コード例 #1
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 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));
 }
コード例 #2
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 public async Task RetryAsyncWithReturn()
 {
     // Execute the DoWorkAsync
     int i = await Retry.ExecuteAsync(async() =>
     {
         return(await DummyMethods.DoWorkAsyncAndReturn());
     }, TimeSpan.FromMilliseconds(100), 2);
 }
コード例 #3
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 public async Task RetryAsync()
 {
     // Execute the DoWorkAsync
     await Retry.ExecuteAsync(async() =>
     {
         await DummyMethods.DoWorkAsync();
     }, TimeSpan.FromMilliseconds(100), 2);
 }
コード例 #4
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 public async Task RetryAsyncWithAllFeatures()
 {
     // Execute the DoWorkAsync
     await Retry.ExecuteAsync(async() => await DummyMethods.DoWorkAsync(), TimeSpan.FromMilliseconds(100), 2, DummyMethods.ExecuteOnExceptionAsync, DummyMethods.ExecuteOnExceptionAsync, typeof(ArgumentException));
 }
コード例 #5
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 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);
 }
コード例 #6
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 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);
 }
コード例 #7
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 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) });
 }
コード例 #8
0
ファイル: SampleUsage.cs プロジェクト: omidnasri/SimpleRetry
 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));
 }