Skip to content

Instantly share code, notes, and snippets.

@ChaseFlorell ChaseFlorell/HttpRestService.cs Secret
Created Aug 13, 2014

Embed
What would you like to do?
GetAsync with Retry
public static async Task<HttpResponseMessage> GetWithRetriesAsync(string url,
AuthenticationHeaderValue authenticationHeaderValue,
MediaTypeWithQualityHeaderValue mediaTypeWithQualityHeaderValue)
{
var numberOfAttempts = 0;
AggregateException capturedException;
do
{
try
{
return await GetAsync(url, authenticationHeaderValue, mediaTypeWithQualityHeaderValue);
}
catch (AggregateException ex)
{
numberOfAttempts++;
capturedException = ex;
}
} while (numberOfAttempts < TotalNumberOfAttempts);
throw capturedException;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.