Skip to content

Commit 944104a

Browse files
committed
Fix: .ctor must be called on the UI thread.
1 parent 95d1d8b commit 944104a

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/ExtensionManager.Vsix.Shared/ExtensionManagerPackage.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
using Microsoft.VisualStudio;
2020
using Microsoft.VisualStudio.Shell;
2121

22+
using ShellSolutionEvents = Microsoft.VisualStudio.Shell.Events.SolutionEvents;
2223
using Task = System.Threading.Tasks.Task;
2324

2425
#nullable enable
@@ -79,24 +80,21 @@ private static async Task<IVSServiceFactory> CreateVSServiceFactoryAsync()
7980
private async Task HandleSolutionExtensionsAsync(IVSSolutions solutions, IFeatureExecutor executor)
8081
{
8182
if (await solutions.IsOpenAsync())
82-
{
83-
JoinableTaskFactory
84-
.RunAsync(() => InstallSolutionExtensionsOnIdleAsync(executor))
85-
.FileAndForget($"{nameof(ExtensionManager)}/{nameof(InstallSolutionExtensionsOnIdleAsync)}");
86-
}
83+
InstallSolutionExtensionsOnIdle(executor);
8784

88-
VS.Events.SolutionEvents.OnAfterOpenSolution += s =>
85+
ShellSolutionEvents.OnAfterOpenSolution += (s, e) =>
8986
{
9087
if (_isFeatureExecuting)
9188
return;
9289

93-
_ = InstallSolutionExtensionsOnIdleAsync(executor);
90+
InstallSolutionExtensionsOnIdle(executor);
9491
};
9592

96-
static async Task InstallSolutionExtensionsOnIdleAsync(IFeatureExecutor executor)
93+
void InstallSolutionExtensionsOnIdle(IFeatureExecutor executor)
9794
{
98-
await ThreadHelper.JoinableTaskFactory.StartOnIdle(
99-
executor.ExecuteAsync<InstallForSolutionFeature>);
95+
JoinableTaskFactory
96+
.StartOnIdle(executor.ExecuteAsync<InstallForSolutionFeature>)
97+
.FileAndForget($"{nameof(ExtensionManager)}/{nameof(InstallForSolutionFeature)}");
10098
}
10199
}
102100

0 commit comments

Comments
 (0)