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

Commit 7cb1dea

Browse files
committed
Always call FindBindingPaths on UI thread
1 parent 7b312d3 commit 7cb1dea

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/GitHub.VisualStudio/GitHubPackage.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,8 @@ async Task CheckBindingPathsAsync()
188188
// When running in the Exp instance, ensure there is only one active binding path.
189189
// This is necessary when the regular (AllUsers) extension is also installed.
190190
// See: https://github.com/github/VisualStudio/issues/1995
191-
await BindingPathHelper.CheckBindingPathsAsync(GetType().Assembly, JoinableTaskFactory, this);
191+
await JoinableTaskFactory.SwitchToMainThreadAsync();
192+
BindingPathHelper.CheckBindingPaths(GetType().Assembly, this);
192193
}
193194
catch (Exception e)
194195
{

src/GitHub.VisualStudio/Helpers/BindingPathHelper.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@
66
using GitHub.Logging;
77
using Microsoft.VisualStudio.Shell;
88
using Microsoft.VisualStudio.Shell.Interop;
9-
using Microsoft.VisualStudio.Threading;
109
using Serilog;
11-
using Task = System.Threading.Tasks.Task;
1210

1311
namespace GitHub.VisualStudio.Helpers
1412
{
@@ -23,13 +21,11 @@ class BindingPathHelper
2321
{
2422
static readonly ILogger log = LogManager.ForContext<BindingPathHelper>();
2523

26-
internal async static Task CheckBindingPathsAsync(
27-
Assembly assembly,
28-
JoinableTaskFactory jtf,
29-
IServiceProvider serviceProvider)
24+
internal static void CheckBindingPaths(Assembly assembly, IServiceProvider serviceProvider)
3025
{
3126
log.Information("Looking for assembly on wrong binding path");
3227

28+
ThreadHelper.CheckAccess();
3329
var bindingPaths = BindingPathUtilities.FindBindingPaths(serviceProvider);
3430
var bindingPath = BindingPathUtilities.FindRedundantBindingPaths(bindingPaths, assembly.Location)
3531
.FirstOrDefault();
@@ -42,7 +38,6 @@ internal async static Task CheckBindingPathsAsync(
4238
// Log what has been detected
4339
log.Warning("Found assembly on wrong binding path {BindingPath}", bindingPath);
4440

45-
await jtf.SwitchToMainThreadAsync();
4641
var message = string.Format(@"Found assembly on wrong binding path:
4742
{0}
4843

0 commit comments

Comments
 (0)