提交 8f753ec7 编写于 作者: M Manish Vasani

Switch to UI thread before invoking Workspace.TryApplyChanges

We recently changed this code to switch from using the Workspace Options setter (now deprecated) to Workspace.TryApplyChanges. This causes an intermittent exception [here](https://github.com/dotnet/roslyn/blob/aeb47891e92341b700c3a290a92553b8a91b445a/src/VisualStudio/Core/Def/Implementation/ProjectSystem/VisualStudioWorkspaceImpl.cs#L374-L377) when TryApplyChanges is invoked from a background thread.

Fixes internal Watson bug [#1062942](https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1062942)
上级 63457148
......@@ -212,7 +212,11 @@ private async Task UpdateStateMachineWorkerAsync(CancellationToken cancellationT
break;
}
// Apply the new options.
// We need to switch to UI thread to invoke TryApplyChanges.
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);
_workspace.TryApplyChanges(_workspace.CurrentSolution.WithOptions(options));
if (options.GetOption(KeybindingResetOptions.NeedsReset))
{
ShowGoldBar();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册