Right way to close WPF GUI application: GetCurrentProcess().Kill(), Environment.Exit(0) or this.Shutdown() Right way to close WPF GUI application: GetCurrentProcess().Kill(), Environment.Exit(0) or this.Shutdown() wpf wpf

Right way to close WPF GUI application: GetCurrentProcess().Kill(), Environment.Exit(0) or this.Shutdown()


Application.Current.Shutdown() is the proper way to shutdown an application. Generally because fire the exit events that you can handle more

Process.GetCurrentProcess().Kill() should be used when you want to kill the application. more

Ad1. The nature of those methods are totally different. The shutdown process can be paused to end some operations, kill force the application to close.

Ad2. Probably Kill() will be the fastest way, but this is something like kernel panic.

Ad3. Shutdown because it fires the close event

Ad4. That depend what this is.


Use Application.Current.Shutdown();

Add ShutdownMode="OnMainWindowClose" in App.xaml


private void ExitMenu_Click(object sender, RoutedEventArgs e)    {        Application.Current.Shutdown();    }