提交 6c4173ff 编写于 作者: J Jason Malinowski

Allow NavigationBarController to handle background thread changes

We might disconnect/reconnect on background threads now, so
be ready for that.
上级 41dda865
......@@ -94,8 +94,6 @@ private void OnWorkspaceRegistrationChanged(object sender, EventArgs e)
private void ConnectToWorkspace(Workspace workspace)
{
AssertIsForeground();
// If we disconnected before the workspace ever connected, just disregard
if (_disconnected)
{
......@@ -105,8 +103,26 @@ private void ConnectToWorkspace(Workspace workspace)
_workspace = workspace;
_workspace.WorkspaceChanged += this.OnWorkspaceChanged;
// For the first time you open the file, we'll start immediately
StartModelUpdateAndSelectedItemUpdateTasks(modelUpdateDelay: 0, selectedItemUpdateDelay: 0, updateUIWhenDone: true);
void connectToNewWorkspace()
{
// For the first time you open the file, we'll start immediately
StartModelUpdateAndSelectedItemUpdateTasks(modelUpdateDelay: 0, selectedItemUpdateDelay: 0, updateUIWhenDone: true);
}
if (IsForeground())
{
connectToNewWorkspace();
}
else
{
var asyncToken = _asyncListener.BeginAsyncOperation(nameof(ConnectToWorkspace));
Task.Run(async () =>
{
await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync();
connectToNewWorkspace();
}).CompletesAsyncOperation(asyncToken);
}
}
private void DisconnectFromWorkspace()
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册