Skip to content

Commit

Permalink
Added some no-capture Awaitable configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
alandoherty committed Nov 21, 2018
1 parent e265a1d commit 0c0053f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/WifiPlug.Api/ApiClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,14 @@ public Uri BaseAddress {

for (int i = 0; i < _retryCount; i++) {
try {
return await RawRequestAsync(method, path, content, cancellationToken);
return await RawRequestAsync(method, path, content, cancellationToken).ConfigureAwait(false);
} catch(ApiException ex) {
if (ex.StatusCode == HttpStatusCode.BadGateway && i < _retryCount - 1) {
await Task.Delay(_retryDelay, cancellationToken);
await Task.Delay(_retryDelay, cancellationToken).ConfigureAwait(false);
continue;
} else if (ex.StatusCode == HttpStatusCode.Unauthorized && _authentication != null && !hasReauthorised) {
// try and reauthorize
bool success = await _authentication.ReauthorizeAsync(this);
bool success = await _authentication.ReauthorizeAsync(this).ConfigureAwait(false);

// if we're successful we don't count this as a retry, note that we store this
// this prevents an infinite loop and gives us retryCount + 1 if we had to reauthorise
Expand Down Expand Up @@ -413,7 +413,7 @@ await RequestAsync(method, path, content, cancellationToken).ConfigureAwait(fals
/// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The ping response.</returns>
public async Task<string> PingAsync(CancellationToken cancellationToken = default(CancellationToken)) {
return await (await RequestAsync(HttpMethod.Get, "ping", null, cancellationToken)).Content.ReadAsStringAsync();
return await (await RequestAsync(HttpMethod.Get, "ping", null, cancellationToken).ConfigureAwait(false)).Content.ReadAsStringAsync().ConfigureAwait(false);
}
#endregion

Expand Down

0 comments on commit 0c0053f

Please sign in to comment.