Force application close on system shutdown

前端 未结 5 1527
臣服心动
臣服心动 2020-12-29 22:18

I have a Windows Forms application that when the Main Window is closing, it displays a basic dialog box, confirming the action. If the user decides to cancel the application

5条回答
  •  伪装坚强ぢ
    2020-12-29 22:35

    SystemEvents can help you. The SessionEnding occurs when the user is trying to log off or shut down the system.

    Microsoft.Win32.SystemEvents.SessionEnding += (sender, e) => DoYourJob();
    

提交回复
热议问题