Skip to content

Commit b085b72

Browse files
authored
Merge pull request #41461 from mavasani/FixTryApplyChangesCrash
Switch to UI thread before invoking Workspace.TryApplyChanges
2 parents e49b283 + 8f753ec commit b085b72

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/VisualStudio/Core/Def/Implementation/Experimentation/KeybindingResetDetector.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,11 @@ private async Task UpdateStateMachineWorkerAsync(CancellationToken cancellationT
212212
break;
213213
}
214214

215+
// Apply the new options.
216+
// We need to switch to UI thread to invoke TryApplyChanges.
217+
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
215218
_workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(options));
219+
216220
if (options.GetOption(KeybindingResetOptions.NeedsReset))
217221
{
218222
ShowGoldBar();

0 commit comments

Comments
 (0)