/// <summary> /// 启动主程序状态检测 /// </summary> /// <param name="mainAppPath"></param> private void StartMainAppStateDetect(string mainAppPath, LocalRunInfo localRunInfo, Config config) { if (_mainAppStateDetector != null) { _mainAppStateDetector.Stop(); _mainAppStateDetector.OnMainAppsClose -= OnMainAppsClose; _mainAppStateDetector.OnCommandRequest -= OnServerCommandRequest; } _mainAppStateDetector = new MainAppStateDetector(mainAppPath, localRunInfo, config); _mainAppStateDetector.OnMainAppsClose += OnMainAppsClose; _mainAppStateDetector.OnCommandRequest += OnServerCommandRequest; _mainAppStateDetector.Start(); }
/// <summary> /// 所有主程序关闭事件 /// </summary> /// <param name="detector"></param> private void OnMainAppsClose(MainAppStateDetector detector, LocalRunInfo localRunInfo) { this.Invoke((Action)(() => { if (!this._config.KeepUpdaterRunning) { Exit(null); } else if (this._config.KeepAppRunning) { if (!UpdateHelper.IsAppRunning(_mainAppPath)) { UpdateHelper.RunMainApp(localRunInfo, "由更新程序启动"); } } })); }