diff --git a/src/MeoAsstGui/Helper/AsstProxy.cs b/src/MeoAsstGui/Helper/AsstProxy.cs index cba2363d61..c1e7c35b9a 100644 --- a/src/MeoAsstGui/Helper/AsstProxy.cs +++ b/src/MeoAsstGui/Helper/AsstProxy.cs @@ -153,7 +153,7 @@ namespace MeoAsstGui Execute.OnUIThread(() => { _windowManager.ShowMessageBox("出现未知异常", "错误", icon: MessageBoxImage.Error); - Environment.Exit(0); + App.Current.Shutdown(); }); } var mainModel = _container.Get(); @@ -217,7 +217,7 @@ namespace MeoAsstGui case AsstMsg.InitFailed: _windowManager.ShowMessageBox("初始化错误!请检查是否使用了中文路径", "错误", icon: MessageBoxImage.Error); - Environment.Exit(0); + App.Current.Shutdown(); break; case AsstMsg.ConnectionInfo: diff --git a/src/MeoAsstGui/Helper/ToastNotification.cs b/src/MeoAsstGui/Helper/ToastNotification.cs index f67dc394fd..d3a3f7206f 100644 --- a/src/MeoAsstGui/Helper/ToastNotification.cs +++ b/src/MeoAsstGui/Helper/ToastNotification.cs @@ -553,7 +553,7 @@ namespace MeoAsstGui { var fInfo = new FLASHWINFO(); fInfo.cbSize = Convert.ToUInt32(Marshal.SizeOf(fInfo)); - fInfo.hwnd = hWnd != default ? hWnd : new WindowInteropHelper(Application.Current.MainWindow).Handle; + fInfo.hwnd = hWnd != default ? hWnd : new WindowInteropHelper(App.Current.MainWindow).Handle; fInfo.dwFlags = (uint)type; fInfo.uCount = count; fInfo.dwTimeout = 0; diff --git a/src/MeoAsstGui/Helper/TrayIcon.cs b/src/MeoAsstGui/Helper/TrayIcon.cs index 6c92d40b91..7b6e6ab49a 100644 --- a/src/MeoAsstGui/Helper/TrayIcon.cs +++ b/src/MeoAsstGui/Helper/TrayIcon.cs @@ -102,7 +102,7 @@ namespace MeoAsstGui private void App_exit(object sender, EventArgs e) { - System.Windows.Application.Current.Shutdown(); + App.Current.Shutdown(); } private void App_show(object sender, EventArgs e) diff --git a/src/MeoAsstGui/ViewModels/RootViewModel.cs b/src/MeoAsstGui/ViewModels/RootViewModel.cs index 17d137013a..56663013e3 100644 --- a/src/MeoAsstGui/ViewModels/RootViewModel.cs +++ b/src/MeoAsstGui/ViewModels/RootViewModel.cs @@ -99,7 +99,7 @@ namespace MeoAsstGui protected override void OnClose() { - System.Windows.Application.Current.Shutdown(); + App.Current.Shutdown(); } } } diff --git a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs index 2239c198d0..c13fb0e907 100644 --- a/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs +++ b/src/MeoAsstGui/ViewModels/TaskQueueViewModel.cs @@ -884,11 +884,9 @@ namespace MeoAsstGui break; case ActionType.ExitSelf: - if (new ToastNotification().CheckToastSystem()) - { - ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知 - } - Environment.Exit(0); + // Shutdown 会调用 OnExit 但 Exit 不会 + App.Current.Shutdown(); + // Enviroment.Exit(0); break; case ActionType.ExitEmulator: @@ -903,11 +901,9 @@ namespace MeoAsstGui { AddLog("模拟器关闭失败", "DarkRed"); } - if (new ToastNotification().CheckToastSystem()) - { - ToastNotificationManagerCompat.History.Clear(); //exit似乎不会走bootstapper,单独清一下通知 - } - Environment.Exit(0); + // Shutdown 会调用 OnExit 但 Exit 不会 + App.Current.Shutdown(); + // Enviroment.Exit(0); break; case ActionType.Shutdown: diff --git a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs index 6379b96f2d..00861a35ca 100644 --- a/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs +++ b/src/MeoAsstGui/ViewModels/VersionUpdateViewModel.cs @@ -242,7 +242,7 @@ namespace MeoAsstGui newProcess.StartInfo.FileName = AppDomain.CurrentDomain.FriendlyName; newProcess.StartInfo.WorkingDirectory = Directory.GetCurrentDirectory(); newProcess.Start(); - Application.Current.Shutdown(); + App.Current.Shutdown(); return true; }