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(); } } }