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

Commit 4d7a426

Browse files
committed
Replace InvokeAsync with SwitchToMainThreadAsync
ThreadingHelper.MainThreadDispatcher.InvokeAsync was causing worse problems than ThreadingHelper.SwitchToMainThreadAsync. Revert back to using ThreadingHelper.SwitchToMainThreadAsync.
1 parent f8b3e9d commit 4d7a426

File tree

3 files changed

+15
-20
lines changed

3 files changed

+15
-20
lines changed

src/GitHub.InlineReviews/InlineReviewsPackage.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,10 @@ protected override async Task InitializeAsync(
2828
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
2929
var exports = componentModel.DefaultExportProvider;
3030

31-
// await ThreadingHelper.SwitchToMainThreadAsync() won't return until after a solution
32-
// has been loaded. We're using the following instead as a workaround.
33-
await ThreadingHelper.MainThreadDispatcher.InvokeAsync(() =>
34-
menuService.AddCommands(
31+
await ThreadingHelper.SwitchToMainThreadAsync();
32+
menuService.AddCommands(
3533
exports.GetExportedValue<INextInlineCommentCommand>(),
36-
exports.GetExportedValue<IPreviousInlineCommentCommand>()));
34+
exports.GetExportedValue<IPreviousInlineCommentCommand>());
3735
}
3836
}
3937
}

src/GitHub.InlineReviews/PullRequestStatusBarPackage.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
2424
var serviceProvider = (IGitHubServiceProvider)await GetServiceAsync(typeof(IGitHubServiceProvider));
2525
var barManager = new PullRequestStatusBarManager(usageTracker, serviceProvider);
2626

27-
// await ThreadingHelper.SwitchToMainThreadAsync() won't return until after a solution
28-
// has been loaded. We're using the following instead as a workaround.
29-
await ThreadingHelper.MainThreadDispatcher.InvokeAsync(() => barManager.StartShowingStatus());
27+
await ThreadingHelper.SwitchToMainThreadAsync();
28+
barManager.StartShowingStatus();
3029
}
3130
}
3231
}

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,16 @@ async Task InitializeMenus()
5959
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
6060
var exports = componentModel.DefaultExportProvider;
6161

62-
// await ThreadingHelper.SwitchToMainThreadAsync() won't return until after a solution
63-
// has been loaded. We're using the following instead as a workaround.
64-
await ThreadingHelper.MainThreadDispatcher.InvokeAsync(() =>
65-
menuService.AddCommands(
66-
exports.GetExportedValue<IAddConnectionCommand>(),
67-
exports.GetExportedValue<IBlameLinkCommand>(),
68-
exports.GetExportedValue<ICopyLinkCommand>(),
69-
exports.GetExportedValue<ICreateGistCommand>(),
70-
exports.GetExportedValue<IOpenLinkCommand>(),
71-
exports.GetExportedValue<IOpenPullRequestsCommand>(),
72-
exports.GetExportedValue<IShowCurrentPullRequestCommand>(),
73-
exports.GetExportedValue<IShowGitHubPaneCommand>()));
62+
await ThreadingHelper.SwitchToMainThreadAsync();
63+
menuService.AddCommands(
64+
exports.GetExportedValue<IAddConnectionCommand>(),
65+
exports.GetExportedValue<IBlameLinkCommand>(),
66+
exports.GetExportedValue<ICopyLinkCommand>(),
67+
exports.GetExportedValue<ICreateGistCommand>(),
68+
exports.GetExportedValue<IOpenLinkCommand>(),
69+
exports.GetExportedValue<IOpenPullRequestsCommand>(),
70+
exports.GetExportedValue<IShowCurrentPullRequestCommand>(),
71+
exports.GetExportedValue<IShowGitHubPaneCommand>());
7472
}
7573

7674
async Task EnsurePackageLoaded(Guid packageGuid)

0 commit comments

Comments
 (0)