简体   繁体   中英

Catch windows shutdown event in a wpf application

I have ac# 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 the user logs off/shutdown the computer.

I have found ways to catch this event in winforms programs ( here , and here ). but i cant figure out how to achieve this in a WPF application.

I'm trying to halt the shutdown until my program is ready to exit

有一个内置事件Application.SessionEnding - 当用户注销或关闭计算机时会触发此事件...您只需要订阅它并将您的代码保存在那里...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM