public static Task <T> ExecuteAsync <TPolicyArg1>(Func <TPolicyArg1, Task <T> > callbackMethod, IRetryPolicy <TPolicyArg1> retryPolicy, Func <TPolicyArg1, Task <T> > inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken = default(CancellationToken), Action <Exception> preRetryCallback = null) { TPolicyArg1 policyArg = (TPolicyArg1)retryPolicy.InitialArgumentValue; Func <Task <T> > inBackoffAlternateCallbackMethod2 = null; if (inBackoffAlternateCallbackMethod != null) { inBackoffAlternateCallbackMethod2 = (() => inBackoffAlternateCallbackMethod((TPolicyArg1)policyArg)); } return(ExecuteRetryAsync(() => callbackMethod((TPolicyArg1)policyArg), async delegate(Exception exception, CancellationToken token) { ShouldRetryResult <TPolicyArg1> shouldRetryResult = await retryPolicy.ShouldRetryAsync(exception, cancellationToken); policyArg = (TPolicyArg1)shouldRetryResult.PolicyArg1; return shouldRetryResult; }, inBackoffAlternateCallbackMethod2, minBackoffForInBackoffCallback, cancellationToken, preRetryCallback)); }
public static Task <T> ExecuteAsync(Func <Task <T> > callbackMethod, IRetryPolicy retryPolicy, Func <Task <T> > inBackoffAlternateCallbackMethod, TimeSpan minBackoffForInBackoffCallback, CancellationToken cancellationToken = default(CancellationToken), Action <Exception> preRetryCallback = null) { Func <Task <T> > inBackoffAlternateCallbackMethod2 = null; if (inBackoffAlternateCallbackMethod != null) { inBackoffAlternateCallbackMethod2 = (() => inBackoffAlternateCallbackMethod()); } return(ExecuteRetryAsync(() => callbackMethod(), (Exception exception, CancellationToken token) => retryPolicy.ShouldRetryAsync(exception, cancellationToken), inBackoffAlternateCallbackMethod2, minBackoffForInBackoffCallback, cancellationToken, preRetryCallback)); }
public static Task <T> ExecuteAsync(Func <Task <T> > callbackMethod, IRetryPolicy retryPolicy, CancellationToken cancellationToken = default(CancellationToken), Action <Exception> preRetryCallback = null) { return(ExecuteRetryAsync(() => callbackMethod(), (Exception exception, CancellationToken token) => retryPolicy.ShouldRetryAsync(exception, cancellationToken), null, TimeSpan.Zero, cancellationToken, preRetryCallback)); }