通知图标停留在系统托盘中的应用关闭停留在、图标、系统托盘、通知

2023-09-03 03:41:34 作者:三好不良少年°

我只从系统托盘中运行的应用程序,它的唯一目的是通过金球奖提示,以提供信息的用户。

I have an application which runs only from the System Tray, it's only purpose is to provide the user with information via Ballon Tips.

它是从一个小麻烦运行良好,除了。当应用程序使用任务管理器(而不是使用上下文菜单)关闭图标坚持围绕在系统托盘中,直到您悬停,然后另一个实例被打开,当你得到第二个图标,坐在第一旁边。

It's running well, apart from one minor annoyance. When the application is closed using the Task Manager (as opposed to using the context menu) the icon sticks around in the system tray, until you hover over it, then when another instance is opened you get a second icon sitting beside the first.

我形成闭合事件看起来是这样的,它什么都不做:

My Form Closed event looks like this, it does nothing:

private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
{
    ntfyIcon.Visible = false;
    ntfyIcon.Icon = null;
    ntfyIcon.Visible = false;
    ntfyIcon.Dispose();
}

这has据报道在Microsoft Connect上并已关闭了微软在不修复作为,显然,这是什么是应该发生的,但我希望有人的溶液

This has been reported on Microsoft Connect and has been closed by Microsoft under Won't Fix as, apparently, this is what is supposed to happen but I was hoping that somebody had a solution.

我在想的东西沿清洗系统托盘上应用的线开?

I was thinking something along the lines of cleaning the system tray on application open?

感谢

推荐答案

对我来说,当调用 Application.DoEvents()设置后,工作图标和处置的的NotifyIcon

For me, it works when calling Application.DoEvents() after settings Icon to null and disposing the NotifyIcon.

private void frmMain_FormClosed(object sender, FormClosedEventArgs e)
{
    ntfyIcon.Icon = null;
    ntfyIcon.Dispose();
    System.Windows.Forms.Application.DoEvents();
}