Using the C # Stop Tray

I have this C # application that starts by loading the system into the tray, and I have the following problem: only on Windows XP

I can not restart the computer while the application is running. If I use file> exit, it stops fine, and then I can restart. but if I try to restart the application open, it just won’t do it

I tried to add this to the constructor of the main window, I don’t know if this should be done correctly:

Application.ApplicationExit += new EventHandler(this.OnApplicationExit);

and the OnApplicationExit function performs the application closing procedure, but this does not help

any ideas?

+3
source share
2 answers

FormClosing -, - e.Cancel = true;?

, , , , :

if(e.CloseReason != WindowsShutDown)
     e.Cancel = true;

CloseReasons, , MSDN.

+4

, Cancel = true - .

+1

Source: https://habr.com/ru/post/1768408/


All Articles