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 it fires the exit events, that you can handle, further info.

Process.GetCurrentProcess().Kill() should be used when you want to kill the application as soon as possible, further info.

The nature of those methods is totally different:

  • Shutdown() can be paused to end some operations
  • Kill() forces the application to close immediately, as soon as possible

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

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)