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

Use vs-threading extensions where available #69932

Merged
merged 1 commit into from
Sep 20, 2023

Conversation

sharwell
Copy link
Member

* Avoid throwing cancellation exceptions (follow-up to dotnet#68412)
* Use provided NoThrowAwaitable extension method
@sharwell sharwell requested a review from a team as a code owner September 13, 2023 17:26
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Sep 13, 2023
@@ -307,11 +307,11 @@ static async Task WaitForHighPriorityTasksAsync(CancellationToken cancellationTo
if (task.IsCompleted)
{
// Make sure to yield so continuations of 'task' can make progress.
await Task.Yield().ConfigureAwait(false);
await AwaitExtensions.ConfigureAwait(Task.Yield(), false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious why it needs to be called in extension form.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Roslyn has the same extension defined in Roslyn.Utilities, and unlike how we handled NoThrowAwaitable it wasn't renamed to ConfigureAwaitInternal.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove that though, and just use the new extension instead? (this can all come in a later PR of coursE).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

➡️ Not trivially. It could be renamed, but this was the only potential conflict location. There are several references in workspaces/features where the conflict can't occur.

await _dataSource.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
#pragma warning disable VSTHRD004 // Await SwitchToMainThreadAsync
await _dataSource.ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken).NoThrowAwaitable();
#pragma warning restore VSTHRD004 // Await SwitchToMainThreadAsync
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

False positive reported as microsoft/vs-threading#1232

@sharwell sharwell merged commit 6ce30cb into dotnet:main Sep 20, 2023
24 checks passed
@ghost ghost added this to the Next milestone Sep 20, 2023
@Cosifne Cosifne modified the milestones: Next, 17.8 P3 Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants