Skip to content

Conversation

@davidwengier
Copy link
Member

Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2268495 ( AB#2268495 but I don't think that works any more 😔)

@davidwengier davidwengier requested a review from a team as a code owner February 23, 2025 21:30
@ghost ghost added Area-IDE untriaged Issues and PRs which have not yet been triaged by a lead labels Feb 23, 2025
@davidwengier davidwengier merged commit 796756b into dotnet:main Feb 26, 2025
25 checks passed
@davidwengier davidwengier deleted the ExplicitlyGetOffTheMainThread branch February 26, 2025 01:17
@dotnet-policy-service dotnet-policy-service bot added this to the Next milestone Feb 26, 2025
// UIContext will already be active, so this method will be immediately called on the new instance.
if (cancellationToken.IsCancellationRequested) return;

await TaskScheduler.Default.SwitchTo(alwaysYield: true);
Copy link
Contributor

Choose a reason for hiding this comment

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

SwitchTo(alwaysYield: true);

Just so I'm clear, the SwitchTo isn't necessary as the concern is about leaving the main thread, right?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, or maybe you just don't want to block the calling thread, even if it's a threadpool thread. I see.

Copy link
Member Author

@davidwengier davidwengier Feb 26, 2025

Choose a reason for hiding this comment

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

Probably not necessary in the real world, but in theory the UI context could have been activated before we got here (in future if the conditions for the context change), or we could be in VS Code (in future) and I thought getting out of the way of the LSP servers initialize handler is probably kind regardless.

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.

5 participants