Skip to content

Commit

Permalink
pass some missing cancellation tokens (#4503)
Browse files Browse the repository at this point in the history
* pass some missing cancellation tokens

* Update RegionManager.cs

* Update JContainer.Async.cs
  • Loading branch information
SimonCropp authored Jan 19, 2024
1 parent 7a051e9 commit 2a0aa37
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ protected override async Task<HttpResponse> SendRequestAsync(
if (isRetriable && retry)
{
logger.Info("Retrying one more time..");
await Task.Delay(TimeSpan.FromSeconds(1)).ConfigureAwait(false);
await Task.Delay(TimeSpan.FromSeconds(1), cancellationToken).ConfigureAwait(false);
return await SendRequestAsync(
endpoint,
headers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ private async Task<RegionInfo> DiscoverAndCacheAsync(ILoggerAdapter logger, Canc
private async Task<RegionInfo> DiscoverAsync(ILoggerAdapter logger, CancellationToken requestCancellationToken)
{
RegionInfo result = null;

await _lockDiscover.WaitAsync(requestCancellationToken).ConfigureAwait(false);
try
{
await _lockDiscover.WaitAsync().ConfigureAwait(false);

var regionInfo = GetCachedRegion(logger);
if (regionInfo != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public AuthCodeExchangeComponent(
public Task<MsalTokenResponse> FetchTokensAsync(CancellationToken cancellationToken)
{
AddCcsHeadersToTokenClient();
return _tokenClient.SendTokenRequestAsync(GetBodyParameters());
return _tokenClient.SendTokenRequestAsync(GetBodyParameters(), cancellationToken: cancellationToken);
}

private Dictionary<string, string> GetBodyParameters()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public async Task<AuthorizationResult> AcquireAuthorizationAsync(
sendAuthorizeRequest,
cancellationToken,
TaskCreationOptions.None,
staTaskScheduler).Wait();
staTaskScheduler).Wait(cancellationToken);
}
catch (AggregateException ae)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task<AuthorizationResult> AcquireAuthorizationAsync(
sendAuthorizeRequest,
cancellationToken,
TaskCreationOptions.None,
staTaskScheduler).Wait();
staTaskScheduler).Wait(cancellationToken);
}
catch (AggregateException ae)
{
Expand All @@ -99,7 +99,7 @@ public async Task<AuthorizationResult> AcquireAuthorizationAsync(
sendAuthorizeRequest();
}

return await Task.Factory.StartNew(() => authorizationResult).ConfigureAwait(false);
return await Task.Factory.StartNew(() => authorizationResult, cancellationToken).ConfigureAwait(false);
}

internal AuthorizationResult Authenticate(Uri requestUri, Uri callbackUri, CancellationToken cancellationToken)
Expand Down

0 comments on commit 2a0aa37

Please sign in to comment.