Skip to content

Move more package initialization to BG.#60211

Merged
CyrusNajmabadi merged 30 commits intodotnet:mainfrom
CyrusNajmabadi:moarBGLoad
Mar 28, 2022
Merged

Move more package initialization to BG.#60211
CyrusNajmabadi merged 30 commits intodotnet:mainfrom
CyrusNajmabadi:moarBGLoad

Conversation

@CyrusNajmabadi
Copy link
Copy Markdown
Contributor

@CyrusNajmabadi CyrusNajmabadi commented Mar 16, 2022

Fixes AB#1501477

@CyrusNajmabadi CyrusNajmabadi requested a review from a team as a code owner March 16, 2022 21:41
@ghost ghost added the Area-IDE label Mar 16, 2022
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

@jasonmalinowski PTAL when you have a chance. Thanks!

var reporter = crawlerService.GetProgressReporter(workspace);
public async Task InitializeAsync(IAsyncServiceProvider serviceProvider)
{
_taskCenterService = await serviceProvider.GetServiceAsync<SVsTaskStatusCenterService, IVsTaskStatusCenterService>().ConfigureAwait(false);
Copy link
Copy Markdown
Contributor

@sharwell sharwell Mar 19, 2022

Choose a reason for hiding this comment

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

📝 Make sure this line is not using the GetServiceAsync extension method provided by the VS SDK (it relies on ThreadHelper internally which is incompatible with testing).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It's true that it relies on ThreadHelper. If you're not using the vssdktestfx or something similar to make ThreadHelper work, then ya, this will probably render you code unable to run in your unit tests.

Comment on lines +37 to +38
var solution = await serviceProvider.GetServiceAsync<SVsSolution, IVsSolution>().ConfigureAwait(false);
await _threadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
Copy link
Copy Markdown
Contributor

@sharwell sharwell Mar 19, 2022

Choose a reason for hiding this comment

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

📝 Reverse the order of these two lines, and use ConfigureAwait(true) (fewer context switches on average).

@CyrusNajmabadi CyrusNajmabadi requested a review from a team March 19, 2022 21:28
@CyrusNajmabadi CyrusNajmabadi requested review from a team as code owners March 19, 2022 21:28
@CyrusNajmabadi CyrusNajmabadi changed the base branch from main to release/dev17.3 March 21, 2022 03:28
@CyrusNajmabadi CyrusNajmabadi changed the base branch from release/dev17.3 to main March 21, 2022 03:29
@CyrusNajmabadi
Copy link
Copy Markdown
Contributor Author

Reverse the order of these two lines, and use ConfigureAwait(true) (fewer context switches on average).

But won't that request the service on the UI thread, which is what we're trying to avoid since it can cause UI-thread mef loads?

Copy link
Copy Markdown
Member

@jasonmalinowski jasonmalinowski left a comment

Choose a reason for hiding this comment

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

Nothing major, but a few odd looking spots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants