From da9c2b649b20aa85614180e3bd963a9628d2bf5e Mon Sep 17 00:00:00 2001 From: Stefan Markovic <57057282+stefansjfw@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:39:31 +0200 Subject: [PATCH] [Settings] Close Settings app if running as standalone process after showing message dialog (#19620) ... in Release mode In Debug mode leave settings app running after closing message dialog --- src/settings-ui/Settings.UI/App.xaml.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/settings-ui/Settings.UI/App.xaml.cs b/src/settings-ui/Settings.UI/App.xaml.cs index 78d17cc5b0..62c0e01e5d 100644 --- a/src/settings-ui/Settings.UI/App.xaml.cs +++ b/src/settings-ui/Settings.UI/App.xaml.cs @@ -179,13 +179,25 @@ namespace Microsoft.PowerToys.Settings.UI // Window is also needed to show MessageDialog settingsWindow = new MainWindow(isDark); settingsWindow.Activate(); + +#if !DEBUG + ShowMessageDialogAndExit("The application cannot be run as a standalone process. Please start the application through the runner.", "Forbidden"); +#else ShowMessageDialog("The application cannot be run as a standalone process. Please start the application through the runner.", "Forbidden"); +#endif } } +#if !DEBUG + private async void ShowMessageDialogAndExit(string content, string title = null) +#else private async void ShowMessageDialog(string content, string title = null) +#endif { await ShowDialogAsync(content, title); +#if !DEBUG + this.Exit(); +#endif } public static Task ShowDialogAsync(string content, string title = null)