I have this C# app which starts at system boot in the tray, and i have the following problem with it, only on Windows XP
I can't restart the PC while the application is running. If I use file > exit, it stops ok and then i can restart. but if i try restarting with the application open, it just won't do it
I tried adding this in the main window constructor, dunno if its the right thing to do:
Application.ApplicationExit += new EventHandler(this.OnApplicationExit);
and the OnApplication开发者_如何转开发Exit function does the app's shutting down procedure.. but that doesn't help
any ideas?
Do you have a FormClosing
event handler somewhere where you do something like e.Cancel = true;
?
If so, change it to first look at the close reason to decide if it should cancel or not as:
if(e.CloseReason != WindowsShutDown)
e.Cancel = true;
There might be other CloseReasons where you should also not Cancel the closing so might be worth looking at MSDN for that.
I've seen this happen before if you've got Cancel = true somewhere in your exit handler.
精彩评论