Skip to content

Commit

Permalink
Add soft termination for settings window
Browse files Browse the repository at this point in the history
  • Loading branch information
pizzaboxer committed Sep 27, 2024
1 parent 81c6512 commit fe04b46
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
9 changes: 9 additions & 0 deletions Bloxstrap/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion Bloxstrap/UI/Elements/Settings/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void WpfUiWindow_Closing(object sender, CancelEventArgs e)
App.State.Save();

if (!e.Cancel)
App.Terminate();
App.SoftTerminate();
}
}
}

0 comments on commit fe04b46

Please sign in to comment.