From fe04b468b052df8ca68b921a42c63fe242163686 Mon Sep 17 00:00:00 2001 From: pizzaboxer Date: Fri, 27 Sep 2024 23:33:57 +0100 Subject: [PATCH] Add soft termination for settings window --- Bloxstrap/App.xaml.cs | 9 +++++++++ Bloxstrap/UI/Elements/Settings/MainWindow.xaml.cs | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/Bloxstrap/App.xaml.cs b/Bloxstrap/App.xaml.cs index 373c7eec..2da5155c 100644 --- a/Bloxstrap/App.xaml.cs +++ b/Bloxstrap/App.xaml.cs @@ -66,6 +66,15 @@ public static void Terminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS) Environment.Exit(exitCodeNum); } + public static void SoftTerminate(ErrorCode exitCode = ErrorCode.ERROR_SUCCESS) + { + int exitCodeNum = (int)exitCode; + + Logger.WriteLine("App::SoftTerminate", $"Terminating with exit code {exitCodeNum} ({exitCode})"); + + Current.Dispatcher.Invoke(() => Current.Shutdown(exitCodeNum)); + } + void GlobalExceptionHandler(object sender, DispatcherUnhandledExceptionEventArgs e) { e.Handled = true; diff --git a/Bloxstrap/UI/Elements/Settings/MainWindow.xaml.cs b/Bloxstrap/UI/Elements/Settings/MainWindow.xaml.cs index fda449fe..37e92376 100644 --- a/Bloxstrap/UI/Elements/Settings/MainWindow.xaml.cs +++ b/Bloxstrap/UI/Elements/Settings/MainWindow.xaml.cs @@ -102,7 +102,7 @@ private void WpfUiWindow_Closing(object sender, CancelEventArgs e) App.State.Save(); if (!e.Cancel) - App.Terminate(); + App.SoftTerminate(); } } }