Turn off Windows close event in wpf application

I have a WPF C # application that needs to be saved when closing. Window close / close events work fine if the user closes the program, but they are not called if the user logs out / shuts down the computer.

I found ways to catch this event in winforms programs ( here and here ). but I cannot figure out how to do this in a WPF application.

I try to stop the stop until my program is ready to exit

+8
c # wpf wndproc
source share
1 answer

There is a built-in Application.SessionEnding event - this event is triggered when a user logs out or shuts down the computer ... you just need to subscribe to it and put your code to save the date, etc. there...

+14
source share

All Articles