C#系统停止托盘应用程序(C# system stopping tray application)

编程入门 行业动态 更新时间:2024-10-27 18:27:21
C#系统停止托盘应用程序(C# system stopping tray application)

我有这个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.

更多推荐

本文发布于:2023-08-08 01:27:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466782.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:托盘   应用程序   系统   system   tray

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!