Move MiscellaneousFilesWorkspace construction to background thread #78019
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR restores behavior introduced in #77768 that were reverted in PR #77983.
The revert occurred as it was flagged for causing ddrit regressions in some of the WinformsVS64.Designer tests. I was unable to reproduce this scenario locally,
but the RPS tests are able to reliably hit this issue.
Insertion PR demonstrating no regressions in WinformsVS64.Designer DDRIT tests.
Digging into it a bit indicated that creating the OpenTextBufferProvider on a bg thread somehow created a thread affinity that caused
microsoft.visualstudio.shell.design.ni!DocData.CreateNativeDocData's call to msenv!CEditorManager::RegisterInvisibleEditor's to require an RPC main->bg thread switch.
This breaks the assumptions of RegisterInvisibleEditor and weird things start happening.
Instead, we explicitly create the OpenTextBufferProvider on the main thread.
Compare by commit:
Commit 1:
Restore changes from PR #77768 that were reverted in PR #77983
Commit 2:
1) Force OpenTextBufferProvider to be created on main thread
2) Move MiscellaneousFilesWorkspace to still be on bgthread, but ensure it occurs after OpenTextBufferProvider construction
3) Remove a misleading comment from OpenTextBufferProvider.ctor and add a verification that it's called on the main thread
4) Change CheckForExistingOpenDocumentsAsync to yield the thread so it doesn't block the caller if the work could have been done synchronously.