/// <summary> /// Process workspace rebuild if required. /// </summary> private void ProcessKwsRebuildIfNeeded() { Debug.Assert(m_rebuildStep == KwsRebuildTaskStep.None); if (m_cd.CurrentTask != KwsTask.Rebuild) { return; } // Sanity check. if (m_cd.MainStatus != KwsMainStatus.RebuildRequired) { KLogging.Log("cannot execute rebuild task, " + KwmStrings.Kws + " status is not RebuildRequired"); RequestTaskSwitch(KwsTask.Stop); return; } // We cannot rebuild until the applications are stopped and we're // logged out. if (m_cd.AppStatus != KwsAppStatus.Stopped || m_ks.LoginStatus != KwsLoginStatus.LoggedOut) { return; } // Protect against spurious state changes. m_rebuildStep = KwsRebuildTaskStep.InProgress; try { // Ask the workspace to prepare for rebuild. m_kws.PrepareToRebuild(); if (m_rebuildStep != KwsRebuildTaskStep.InProgress) { return; } // Tell the applications to prepare for rebuild. foreach (KwsApp app in m_kws.AppTree.Values) { app.PrepareToRebuild(); if (m_rebuildStep != KwsRebuildTaskStep.InProgress) { return; } } } catch (Exception ex) { HandleMiscFailure(ex); return; } // We have "rebuilt" the workspace. Update the state. m_rebuildStep = KwsRebuildTaskStep.None; m_cd.MainStatus = KwsMainStatus.Good; m_cd.RebuildFlags = 0; m_cd.Uuid = Wm.MakeUuid(); SetLoginType(KwsLoginType.All); m_kws.OnStateChange(WmStateChange.Permanent); // Switch to the user task. SwitchToUserTask(); }