Answer the question
In order to leave comments, you need to log in
Why doesn't notifyIcon disappear when the program terminates?
Hello,
I wrote a program with one form, attached a notifyIcon to this form, assigned an icon to it.
If the form is closed with a cross, then the tray icon normally disappears, but if this program is terminated in a different way, the icon remains, and disappears only when the mouse is hovered over.
How can this problem be solved?
Thank you very much in advance!
Answer the question
In order to leave comments, you need to log in
Greetings.
private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
notifyIcon1.Visible = false;
notifyIcon1.Dispose();
}
In a sense, this is a feature of Windows. When the program ends incorrectly (crashed in the task manager, stopped in the studio) - the icon does not disappear, because the system does not receive a notification that the icon needs to be crashed. And when hovering, Windows tries to check the attached process, apparently.
Try to bang through the task manager any program hanging in the tray - it will be the same.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question