Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit 7511113

Browse files
committed
Retrieve IGitHubServiceProvider asynchronously
Rather than retrieving SComponentModel asynchronously, we can simply retrieve IGitHubServiceProvider (which has the dependency on SComponentModel).
1 parent cb26608 commit 7511113

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

src/GitHub.VisualStudio/UI/GitHubPane.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,20 @@ protected override void Initialize()
8383
// Using JoinableTaskFactory from parent AsyncPackage. That way if VS shuts down before this
8484
// work is done, we won't risk crashing due to arbitrary work going on in background threads.
8585
var asyncPackage = (AsyncPackage)Package;
86-
viewModelTask = asyncPackage.JoinableTaskFactory.RunAsync(InitializeAsync);
86+
viewModelTask = asyncPackage.JoinableTaskFactory.RunAsync(() => InitializeAsync(asyncPackage));
8787
}
8888

8989
public Task<IGitHubPaneViewModel> GetViewModelAsync() => viewModelTask.JoinAsync();
9090

91-
async Task<IGitHubPaneViewModel> InitializeAsync()
91+
async Task<IGitHubPaneViewModel> InitializeAsync(AsyncPackage asyncPackage)
9292
{
9393
try
9494
{
95-
// Allow MEF to initialize its cache asynchronously
9695
ShowInitializing();
97-
var asyncServiceProvider = (IAsyncServiceProvider)GetService(typeof(SAsyncServiceProvider));
98-
await asyncServiceProvider.GetServiceAsync(typeof(SComponentModel));
9996

100-
var provider = VisualStudio.Services.GitHubServiceProvider;
97+
// Allow MEF to initialize its cache asynchronously
98+
var provider = (IGitHubServiceProvider)await asyncPackage.GetServiceAsync(typeof(IGitHubServiceProvider));
99+
101100
var teServiceHolder = provider.GetService<ITeamExplorerServiceHolder>();
102101
teServiceHolder.ServiceProvider = this;
103102

0 commit comments

Comments
 (0)