-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Explictly jump off the main thread before serializing data to call Razor #77321
Explictly jump off the main thread before serializing data to call Razor #77321
Conversation
{ | ||
// The LSP server will dispose us when the server exits, but VS could decide to activate us later. | ||
// If a new instance of the server is created, a new instance of this class will be created and the | ||
// 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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
Fixes https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2268495 ( AB#2268495 but I don't think that works any more 😔)