Catch windows shutdown event in a wpf application

前端 未结 1 362
梦如初夏
梦如初夏 2020-12-16 18:53

I have a c# WPF application that needs to save data when it closes. The Window Closing/Closed events work fine if the user closes the program, but they do not get called if

相关标签:
1条回答
  • 2020-12-16 19:36

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

    0 讨论(0)
提交回复
热议问题