How to simulate Windows shutdown for debugging?

后端 未结 4 1951
北恋
北恋 2020-12-04 16:54

I have an issue with my application when Windows shuts down - my app isn\'t exiting nicely, resulting in the End Task window being displayed. How can I use the debugger to s

4条回答
  •  攒了一身酷
    2020-12-04 17:22

    You could use the SystemEvents.SessionEnding event, which is fired when a user logs off or shuts down. Be careful when using it though, some resources are not guaranteed to be available. For example, my application needed to hit a server when it was shutting down to clock a user out (a timeclock application), but the network card is sometimes already disabled when this event occurs. Since you're just doing cleanup, this should work fine.

提交回复
热议问题