Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run continuation to dispose of cancellation token source #60653

Merged
merged 3 commits into from
Apr 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public void Shutdown()
_requestTelemetryLogger,
combinedCancellationToken);

// Run a continuation to ensure the cts is disposed of.
// We pass CancellationToken.None as we always want to dispose of the source
// even when the request is cancelled or the queue is shutting down.
_ = resultTask.ContinueWith(_ => combinedTokenSource.Dispose(), CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default);

var didEnqueue = _queue.TryEnqueue((item, combinedCancellationToken));

// If the queue has been shut down the enqueue will fail, so we just fault the task immediately.
Expand Down