我有这个C#应用程序,从托盘中的系统启动开始,我有以下问题,只在Windows XP上
应用程序运行时我无法重启PC。 如果我使用文件>退出,它会停止正常,然后我可以重新启动。 但如果我尝试重新启动应用程序打开,它就不会这样做
我尝试在主窗口构造函数中添加它,dunno如果它是正确的做法:
Application.ApplicationExit += new EventHandler(this.OnApplicationExit);并且OnApplicationExit函数执行应用程序的关闭程序..但这没有帮助
有任何想法吗?
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 OnApplicationExit function does the app's shutting down procedure.. but that doesn't help
any ideas?
最满意答案
你有一个FormClosing事件处理程序,在那里你做一些像e.Cancel = true; ?
如果是这样,请将其更改为首先查看关闭原因以决定是否应该取消:
if(e.CloseReason != WindowsShutDown) e.Cancel = true;可能还有其他的CloseDeasons你也不应该取消关闭,所以可能值得一看MSDN。
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.
更多推荐
发布评论