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