Async async async improvements.

This commit is contained in:
tidusjar 2016-07-29 16:50:35 +01:00
parent 236024e4ae
commit b3e90c7a7f
19 changed files with 785 additions and 755 deletions

View file

@ -33,13 +33,13 @@ namespace PlexRequests.Api
{
public static class RetryHandler
{
private static readonly TimeSpan[] DefaultTime = { TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) };
private static readonly TimeSpan[] DefaultRetryTime = { TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(5), TimeSpan.FromSeconds(10) };
public static T Execute<T>(Func<T> action, TimeSpan[] timeSpan = null)
{
if (timeSpan == null)
{
timeSpan = DefaultTime;
timeSpan = DefaultRetryTime;
}
var policy = RetryAndWaitPolicy(timeSpan);
@ -50,7 +50,7 @@ namespace PlexRequests.Api
{
if (timeSpan == null)
{
timeSpan = DefaultTime;
timeSpan = DefaultRetryTime;
}
var policy = RetryAndWaitPolicy(action, timeSpan);
@ -61,7 +61,7 @@ namespace PlexRequests.Api
{
if (timeSpan == null)
{
timeSpan = DefaultTime;
timeSpan = DefaultRetryTime;
}
var policy = Policy.Handle<Exception>().WaitAndRetry(timeSpan, (e, ts) => action());
@ -72,7 +72,7 @@ namespace PlexRequests.Api
{
if (timeSpan == null)
{
timeSpan = DefaultTime;
timeSpan = DefaultRetryTime;
}
var policy = Policy.Handle<Exception>().WaitAndRetry(timeSpan);
@ -83,7 +83,7 @@ namespace PlexRequests.Api
{
if (timeSpan == null)
{
timeSpan = DefaultTime;
timeSpan = DefaultRetryTime;
}
var policy = Policy.Handle<Exception>().WaitAndRetry(timeSpan, action);