Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an e.CloseReason for WPF?

I'm a big fan of taking control of every possible situation on the computer when it comes to making apps. And now that I'm beginning to use favor WPF over WinForms for some things, I'm also beginning to realize that many really cool things are missing in WPF - and searching for alternatives seems to be a never-ending struggle.

Is there an alternative in WPF to e.CloseReason for WinForms?

like image 924
uSeRnAmEhAhAhAhAhA Avatar asked Jan 18 '14 22:01

uSeRnAmEhAhAhAhAhA


1 Answers

The different "reasons" manifest as separate events. The Closing and Closed events are related to explicitly closing a window, either programmatically or via Alt+F4 or the close button. The Application.SessionEnding event happens at a shutdown or logoff, and information is exposed by ReasonSessionEnding. The exit code from the process can be read from ApplicationExitCode of the Application.Exit event.

like image 169
nmclean Avatar answered Sep 21 '22 14:09

nmclean