|
24 | 24 |
|
25 | 25 | namespace GitHub.VisualStudio |
26 | 26 | { |
27 | | - // Initialize menus on Main thread. |
28 | | - [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = false)] |
| 27 | + [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] |
29 | 28 | [InstalledProductRegistration("#110", "#112", AssemblyVersionInformation.Version, IconResourceID = 400)] |
30 | 29 | [Guid(Guids.guidGitHubPkgString)] |
31 | 30 | [ProvideMenuResource("Menus.ctmenu", 1)] |
32 | | - // Only initialize when we're in the context of a Git repository. |
33 | | - [ProvideAutoLoad(Guids.UIContext_Git)] |
| 31 | + [ProvideAutoLoad(Guids.UIContext_Git, PackageAutoLoadFlags.BackgroundLoad)] |
34 | 32 | [ProvideToolWindow(typeof(GitHubPane), Orientation = ToolWindowOrientation.Right, Style = VsDockStyle.Tabbed, Window = EnvDTE.Constants.vsWindowKindSolutionExplorer)] |
35 | 33 | [ProvideOptionPage(typeof(OptionsPage), "GitHub for Visual Studio", "General", 0, 0, supportsAutomation: true)] |
36 | 34 | public class GitHubPackage : AsyncPackage |
@@ -71,17 +69,20 @@ async Task InitializeMenus() |
71 | 69 | { |
72 | 70 | var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService))); |
73 | 71 | var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel))); |
74 | | - |
75 | 72 | var exports = componentModel.DefaultExportProvider; |
76 | | - menuService.AddCommands( |
77 | | - exports.GetExportedValue<IAddConnectionCommand>(), |
78 | | - exports.GetExportedValue<IBlameLinkCommand>(), |
79 | | - exports.GetExportedValue<ICopyLinkCommand>(), |
80 | | - exports.GetExportedValue<ICreateGistCommand>(), |
81 | | - exports.GetExportedValue<IOpenLinkCommand>(), |
82 | | - exports.GetExportedValue<IOpenPullRequestsCommand>(), |
83 | | - exports.GetExportedValue<IShowCurrentPullRequestCommand>(), |
84 | | - exports.GetExportedValue<IShowGitHubPaneCommand>()); |
| 73 | + |
| 74 | + // await ThreadingHelper.SwitchToMainThreadAsync() won't return until after a solution |
| 75 | + // has been loaded. We're using the following instead as a workaround. |
| 76 | + await ThreadingHelper.MainThreadDispatcher.InvokeAsync(() => |
| 77 | + menuService.AddCommands( |
| 78 | + exports.GetExportedValue<IAddConnectionCommand>(), |
| 79 | + exports.GetExportedValue<IBlameLinkCommand>(), |
| 80 | + exports.GetExportedValue<ICopyLinkCommand>(), |
| 81 | + exports.GetExportedValue<ICreateGistCommand>(), |
| 82 | + exports.GetExportedValue<IOpenLinkCommand>(), |
| 83 | + exports.GetExportedValue<IOpenPullRequestsCommand>(), |
| 84 | + exports.GetExportedValue<IShowCurrentPullRequestCommand>(), |
| 85 | + exports.GetExportedValue<IShowGitHubPaneCommand>())); |
85 | 86 | } |
86 | 87 |
|
87 | 88 | async Task EnsurePackageLoaded(Guid packageGuid) |
|
0 commit comments