/// <summary> /// This method must be called by the application when it has started. /// </summary> public void OnAppStarted() { if (AppStatus != KwsAppStatus.Starting) return; AppStatus = KwsAppStatus.Started; Kws.OnKwsSmNotif += OnKwsSmNotif; Kws.Sm.OnAppStarted(); }
/// <summary> /// Initialization code common to both the deserialized and /// non-deserialized cases. This method must be called explicitly /// when the workspace is deserialized. /// </summary> public virtual void Initialize(IAppHelper appHelper) { Helper = appHelper; Helper.OnKwsStatusChanged += OnKwsStatusChangedInternal; AppStatus = KwsAppStatus.Stopped; DirtyFlag = false; }
/// <summary> /// This method must be called by the application when it has started. /// </summary> public void OnAppStarted() { if (AppStatus != KwsAppStatus.Starting) { return; } AppStatus = KwsAppStatus.Started; Kws.OnKwsSmNotif += OnKwsSmNotif; Kws.Sm.OnAppStarted(); }
/// <summary> /// This method must be called by the application when it has stopped. /// </summary> public void OnAppStopped() { if (AppStatus != KwsAppStatus.Stopping) { return; } AppStatus = KwsAppStatus.Stopped; Kws.OnKwsSmNotif -= OnKwsSmNotif; Kws.Sm.OnAppStopped(); }
/// <summary> /// Stop the applications if they are starting / started. /// </summary> public void StopApp() { if (AppStatus == KwsAppStatus.Stopped || AppStatus == KwsAppStatus.Stopping) return; try { AppStatus = KwsAppStatus.Stopping; foreach (KwsApp app in AppTree.Values) { if (app.AppStatus == KwsAppStatus.Started || app.AppStatus == KwsAppStatus.Starting) app.AppStatus = KwsAppStatus.Stopping; app.RequestStop(); } Sm.OnAppStopped(); } // We cannot handle applications that won't stop. catch (Exception ex) { Base.HandleException(ex, true); } }
/// <summary> /// Start the applications if they are stopped. /// </summary> public void StartApp() { if (AppStatus != KwsAppStatus.Stopped) return; AppStatus = KwsAppStatus.Starting; // Applications have an implicit reference to the workspace when // they aren't stopped. AddRef(); // Try to start the applications, until all applications are started // or a request to stop the applications is received. foreach (KwsApp app in AppTree.Values) { try { if (AppStatus != KwsAppStatus.Starting) break; Debug.Assert(app.AppStatus == KwsAppStatus.Stopped); app.AppStatus = KwsAppStatus.Starting; app.RequestStart(); } catch (Exception ex) { Sm.HandleAppFailure(app, ex); return; } // Required if there are no applications. Sm.OnAppStarted(); } }
/// <summary> /// This method must be called by the application when it has stopped. /// </summary> public void OnAppStopped() { if (AppStatus != KwsAppStatus.Stopping) return; AppStatus = KwsAppStatus.Stopped; Kws.OnKwsSmNotif -= OnKwsSmNotif; Kws.Sm.OnAppStopped(); }
public KwsSmNotifApp(Workspace kws, KwsAppStatus status) : base(kws) { Status = status; }