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

Move more package initialization to BG. #60211

Merged
merged 30 commits into from
Mar 28, 2022

Conversation

CyrusNajmabadi
Copy link
Member

@CyrusNajmabadi CyrusNajmabadi commented Mar 16, 2022

Fixes AB#1501477

@CyrusNajmabadi
Copy link
Member 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
Member

@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
Member Author

Choose a reason for hiding this comment

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

Copy link
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
Member

@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 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
Member 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
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