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

Commit 4746859

Browse files
committed
Cast IMenuCommandService on Main thread
We should always cast STA COM services on Main thread.
1 parent 255b007 commit 4746859

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/GitHub.InlineReviews/InlineReviewsPackage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ protected override async Task InitializeAsync(
3535

3636
async Task InitializeMenus()
3737
{
38-
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
3938
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
4039
var exports = componentModel.DefaultExportProvider;
4140
var commands = new IVsCommandBase[]
@@ -45,6 +44,7 @@ async Task InitializeMenus()
4544
};
4645

4746
await JoinableTaskFactory.SwitchToMainThreadAsync();
47+
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
4848
menuService.AddCommands(commands);
4949
}
5050
}

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ void LogVersionInformation()
5454

5555
async Task InitializeMenus()
5656
{
57-
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
5857
var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel)));
5958
var exports = componentModel.DefaultExportProvider;
6059
var commands = new IVsCommandBase[]
@@ -70,6 +69,7 @@ async Task InitializeMenus()
7069
};
7170

7271
await JoinableTaskFactory.SwitchToMainThreadAsync();
72+
var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService)));
7373
menuService.AddCommands(commands);
7474
}
7575

0 commit comments

Comments
 (0)