diff --git a/Launcher.Next.App/App.xaml.cs b/Launcher.Next.App/App.xaml.cs index 7b0f244..9577b8f 100644 --- a/Launcher.Next.App/App.xaml.cs +++ b/Launcher.Next.App/App.xaml.cs @@ -28,7 +28,16 @@ public partial class App : System.Windows.Application catch (Exception exception) { System.Windows.MessageBox.Show("Controlled local configuration blocked: " + exception.Message, "Launcher Next"); Shutdown(2); } return; } - if (e.Args.FirstOrDefault()?.Equals("pilot", StringComparison.OrdinalIgnoreCase) == true) { Shutdown(await PilotCli.RunAsync(e.Args.Skip(1).ToArray())); return; } + if (e.Args.FirstOrDefault()?.Equals("pilot", StringComparison.OrdinalIgnoreCase) == true) + { + // A pilot command is asynchronous and owns no WPF window. Without an + // explicit shutdown mode the dispatcher may terminate at its first + // await, after the Preview child has been started but before Apply + // and its evidence/rollback boundary have run. + ShutdownMode = System.Windows.ShutdownMode.OnExplicitShutdown; + Shutdown(await PilotCli.RunAsync(e.Args.Skip(1).ToArray())); + return; + } new MainWindow().Show(); } }