In my WPF Main Window I handle the OnClosing event – protected override void OnClosing(CancelEventArgs e). This event is also fired when Windows is shutting down, and tries to close the programs opened.
But, when Windows is shutting down, I would like to have a different logic than I would have if the user had clicked on the X button on the top right. Is there a way to distinguish if the window close was initiated by the user and not by the system?
In my WPF Main Window I handle the OnClosing event – protected override void
Share
You can use the Application.SessionEnding event to trap shutdown/logoff messages, and put your different logic in there.