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

Commit

Permalink
Call MenuCommandService.AddCommand on Main thread
Browse files Browse the repository at this point in the history
Calling on background thread can cause deadlock.
  • Loading branch information
jcansdale committed Mar 6, 2018
1 parent 804f3b3 commit a087725
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/GitHub.VisualStudio/GitHubPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using System.Windows;
using GitHub.Api;
using GitHub.Extensions;
using GitHub.Helpers;
using GitHub.Info;
using GitHub.Logging;
using GitHub.Models;
Expand Down Expand Up @@ -76,6 +77,9 @@ async Task InitializeMenus()
return;
}

// IMenuCommandService.AddCommand uses IServiceProvider.GetService and must be called on Main thread.
await ThreadingHelper.SwitchToMainThreadAsync();

foreach (var menu in menus.Menus)
serviceProvider.AddCommandHandler(menu.Guid, menu.CmdId, (s, e) => menu.Activate());

Expand Down

0 comments on commit a087725

Please sign in to comment.