AsyncRetrySyntax
Fluent API for defining a AsyncRetryPolicy.
using Polly.Retry;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Polly
{
public static class AsyncRetrySyntax
{
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder)
{
return policyBuilder.RetryAsync(1);
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount)
{
Action<Exception, int, Context> onRetry = delegate {
};
return policyBuilder.RetryAsync(retryCount, onRetry);
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Action<Exception, int> onRetry)
{
<>c__DisplayClass2_0 <>4__this;
return policyBuilder.RetryAsync(1, delegate(Exception outcome, int i, Context _) {
<>c__DisplayClass2_0.<<RetryAsync>b__0>d stateMachine = default(<>c__DisplayClass2_0.<<RetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.i = i;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Func<Exception, int, Task> onRetryAsync)
{
return policyBuilder.RetryAsync(1, (Exception outcome, int i, Context _) => onRetryAsync(outcome, i));
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action<Exception, int> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass4_0 <>4__this;
return policyBuilder.RetryAsync(retryCount, delegate(Exception outcome, int i, Context _) {
<>c__DisplayClass4_0.<<RetryAsync>b__0>d stateMachine = default(<>c__DisplayClass4_0.<<RetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.i = i;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<Exception, int, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.RetryAsync(retryCount, (Exception outcome, int i, Context _) => onRetryAsync(outcome, i));
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Action<Exception, int, Context> onRetry)
{
return policyBuilder.RetryAsync(1, onRetry);
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, Func<Exception, int, Context, Task> onRetryAsync)
{
return policyBuilder.RetryAsync(1, onRetryAsync);
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Action<Exception, int, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass8_0 <>4__this;
return policyBuilder.RetryAsync(retryCount, delegate(Exception outcome, int i, Context ctx) {
<>c__DisplayClass8_0.<<RetryAsync>b__0>d stateMachine = default(<>c__DisplayClass8_0.<<RetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.i = i;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<Exception, int, Context, Task> onRetryAsync)
{
if (retryCount < 0)
throw new ArgumentOutOfRangeException("retryCount", "Value must be greater than or equal to zero.");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, (Exception outcome, TimeSpan _, int i, Context ctx) => onRetryAsync(outcome, i, ctx), retryCount, null, null);
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder)
{
Action<Exception> onRetry = delegate {
};
return policyBuilder.RetryForeverAsync(onRetry);
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action<Exception> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass11_0 <>4__this;
return policyBuilder.RetryForeverAsync(delegate(Exception outcome, Context _) {
<>c__DisplayClass11_0.<<RetryForeverAsync>b__0>d stateMachine = default(<>c__DisplayClass11_0.<<RetryForeverAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action<Exception, int> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass12_0 <>4__this;
return policyBuilder.RetryForeverAsync(delegate(Exception outcome, int i, Context _) {
<>c__DisplayClass12_0.<<RetryForeverAsync>b__0>d stateMachine = default(<>c__DisplayClass12_0.<<RetryForeverAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.i = i;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func<Exception, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.RetryForeverAsync((Exception outcome, Context _) => onRetryAsync(outcome));
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func<Exception, int, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.RetryForeverAsync((Exception outcome, int i, Context _) => onRetryAsync(outcome, i));
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action<Exception, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass15_0 <>4__this;
return policyBuilder.RetryForeverAsync(delegate(Exception outcome, Context ctx) {
<>c__DisplayClass15_0.<<RetryForeverAsync>b__0>d stateMachine = default(<>c__DisplayClass15_0.<<RetryForeverAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Action<Exception, int, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass16_0 <>4__this;
return policyBuilder.RetryForeverAsync(delegate(Exception outcome, int i, Context ctx) {
<>c__DisplayClass16_0.<<RetryForeverAsync>b__0>d stateMachine = default(<>c__DisplayClass16_0.<<RetryForeverAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.i = i;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func<Exception, Context, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, (Exception outcome, TimeSpan _, int _, Context ctx) => onRetryAsync(outcome, ctx), 2147483647, null, null);
}
public static AsyncRetryPolicy RetryForeverAsync(this PolicyBuilder policyBuilder, Func<Exception, int, Context, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, (Exception outcome, TimeSpan _, int i, Context ctx) => onRetryAsync(outcome, i, ctx), 2147483647, null, null);
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider)
{
Action<Exception, TimeSpan> onRetry = delegate {
};
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, onRetry);
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass20_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, delegate(Exception outcome, TimeSpan span, int _, Context _) {
<>c__DisplayClass20_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass20_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.span = span;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, (Exception outcome, TimeSpan span, int _, Context _) => onRetryAsync(outcome, span));
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass22_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, delegate(Exception outcome, TimeSpan span, int _, Context ctx) {
<>c__DisplayClass22_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass22_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.span = span;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, (Exception outcome, TimeSpan timespan, int _, Context ctx) => onRetryAsync(outcome, timespan, ctx));
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, int, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass24_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, delegate(Exception outcome, TimeSpan timespan, int i, Context ctx) {
<>c__DisplayClass24_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass24_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.timespan = timespan;
stateMachine.i = i;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
{
if (retryCount < 0)
throw new ArgumentOutOfRangeException("retryCount", "Value must be greater than or equal to zero.");
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
IEnumerable<TimeSpan> sleepDurationsEnumerable = Enumerable.Range(1, retryCount).Select(sleepDurationProvider);
return new AsyncRetryPolicy(policyBuilder, onRetryAsync, retryCount, sleepDurationsEnumerable, null);
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass26_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, delegate(Exception outcome, TimeSpan span, int _, Context ctx) {
<>c__DisplayClass26_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass26_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.span = span;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, (Exception outcome, TimeSpan timespan, int _, Context ctx) => onRetryAsync(outcome, timespan, ctx));
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, int, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass28_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(retryCount, sleepDurationProvider, delegate(Exception outcome, TimeSpan timespan, int i, Context ctx) {
<>c__DisplayClass28_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass28_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.timespan = timespan;
stateMachine.i = i;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
return policyBuilder.WaitAndRetryAsync(retryCount, (int i, Exception _, Context ctx) => sleepDurationProvider(i, ctx), onRetryAsync);
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, int retryCount, Func<int, Exception, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
{
if (retryCount < 0)
throw new ArgumentOutOfRangeException("retryCount", "Value must be greater than or equal to zero.");
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, onRetryAsync, retryCount, null, sleepDurationProvider);
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations)
{
Action<Exception, TimeSpan, int, Context> onRetry = delegate {
};
return policyBuilder.WaitAndRetryAsync(sleepDurations, onRetry);
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<Exception, TimeSpan> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass32_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(sleepDurations, delegate(Exception outcome, TimeSpan timespan, int _, Context _) {
<>c__DisplayClass32_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass32_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.timespan = timespan;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<Exception, TimeSpan, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryAsync(sleepDurations, (Exception outcome, TimeSpan timespan, int _, Context _) => onRetryAsync(outcome, timespan));
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<Exception, TimeSpan, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass34_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(sleepDurations, delegate(Exception outcome, TimeSpan timespan, int _, Context ctx) {
<>c__DisplayClass34_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass34_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.timespan = timespan;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
{
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryAsync(sleepDurations, (Exception outcome, TimeSpan timespan, int _, Context ctx) => onRetryAsync(outcome, timespan, ctx));
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Action<Exception, TimeSpan, int, Context> onRetry)
{
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass36_0 <>4__this;
return policyBuilder.WaitAndRetryAsync(sleepDurations, delegate(Exception outcome, TimeSpan timespan, int i, Context ctx) {
<>c__DisplayClass36_0.<<WaitAndRetryAsync>b__0>d stateMachine = default(<>c__DisplayClass36_0.<<WaitAndRetryAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.outcome = outcome;
stateMachine.timespan = timespan;
stateMachine.i = i;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryAsync(this PolicyBuilder policyBuilder, IEnumerable<TimeSpan> sleepDurations, Func<Exception, TimeSpan, int, Context, Task> onRetryAsync)
{
if (sleepDurations == null)
throw new ArgumentNullException("sleepDurations");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, onRetryAsync, 2147483647, sleepDurations, null);
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
Action<Exception, TimeSpan> onRetry = delegate {
};
return policyBuilder.WaitAndRetryForeverAsync(sleepDurationProvider, onRetry);
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
Action<Exception, TimeSpan, Context> onRetry = delegate {
};
return policyBuilder.WaitAndRetryForeverAsync(sleepDurationProvider, onRetry);
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan> onRetry)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetry == null)
throw new ArgumentNullException("onRetry");
return policyBuilder.WaitAndRetryForeverAsync((int retryCount, Context _) => sleepDurationProvider(retryCount), delegate(Exception exception, TimeSpan timespan, Context _) {
onRetry(exception, timespan);
});
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Action<Exception, int, TimeSpan> onRetry)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetry == null)
throw new ArgumentNullException("onRetry");
return policyBuilder.WaitAndRetryForeverAsync((int retryCount, Context _) => sleepDurationProvider(retryCount), delegate(Exception exception, int i, TimeSpan timespan, Context _) {
onRetry(exception, i, timespan);
});
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryForeverAsync((int retryCount, Context _) => sleepDurationProvider(retryCount), (Exception exception, TimeSpan timespan, Context _) => onRetryAsync(exception, timespan));
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, TimeSpan> sleepDurationProvider, Func<Exception, int, TimeSpan, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return policyBuilder.WaitAndRetryForeverAsync((int retryCount, Context _) => sleepDurationProvider(retryCount), (Exception exception, int i, TimeSpan timespan, Context _) => onRetryAsync(exception, i, timespan));
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, TimeSpan, Context> onRetry)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass44_0 <>4__this;
return policyBuilder.WaitAndRetryForeverAsync(sleepDurationProvider, delegate(Exception exception, TimeSpan timespan, Context ctx) {
<>c__DisplayClass44_0.<<WaitAndRetryForeverAsync>b__0>d stateMachine = default(<>c__DisplayClass44_0.<<WaitAndRetryForeverAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.exception = exception;
stateMachine.timespan = timespan;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Action<Exception, int, TimeSpan, Context> onRetry)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetry == null)
throw new ArgumentNullException("onRetry");
<>c__DisplayClass45_0 <>4__this;
return policyBuilder.WaitAndRetryForeverAsync(sleepDurationProvider, delegate(Exception exception, int i, TimeSpan timespan, Context ctx) {
<>c__DisplayClass45_0.<<WaitAndRetryForeverAsync>b__0>d stateMachine = default(<>c__DisplayClass45_0.<<WaitAndRetryForeverAsync>b__0>d);
stateMachine.<>t__builder = AsyncTaskMethodBuilder.Create();
stateMachine.<>4__this = <>4__this;
stateMachine.exception = exception;
stateMachine.i = i;
stateMachine.timespan = timespan;
stateMachine.ctx = ctx;
stateMachine.<>1__state = -1;
stateMachine.<>t__builder.Start(ref stateMachine);
return stateMachine.<>t__builder.Task;
});
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
return policyBuilder.WaitAndRetryForeverAsync((int i, Exception _, Context ctx) => sleepDurationProvider(i, ctx), onRetryAsync);
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Context, TimeSpan> sleepDurationProvider, Func<Exception, int, TimeSpan, Context, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
return policyBuilder.WaitAndRetryForeverAsync((int i, Exception _, Context ctx) => sleepDurationProvider(i, ctx), onRetryAsync);
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Exception, Context, TimeSpan> sleepDurationProvider, Func<Exception, TimeSpan, Context, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, (Exception outcome, TimeSpan timespan, int _, Context ctx) => onRetryAsync(outcome, timespan, ctx), 2147483647, null, sleepDurationProvider);
}
public static AsyncRetryPolicy WaitAndRetryForeverAsync(this PolicyBuilder policyBuilder, Func<int, Exception, Context, TimeSpan> sleepDurationProvider, Func<Exception, int, TimeSpan, Context, Task> onRetryAsync)
{
if (sleepDurationProvider == null)
throw new ArgumentNullException("sleepDurationProvider");
if (onRetryAsync == null)
throw new ArgumentNullException("onRetryAsync");
return new AsyncRetryPolicy(policyBuilder, (Exception exception, TimeSpan timespan, int i, Context ctx) => onRetryAsync(exception, i, timespan, ctx), 2147483647, null, sleepDurationProvider);
}
}
}