V
V
Vanes Ri_Lax2015-11-09 15:15:46
C++ / C#
Vanes Ri_Lax, 2015-11-09 15:15:46

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

3 answer(s)
M
MonkAlex, 2015-11-09
@MonkAlex

Call
When the program ends.

G
georgich, 2015-11-09
@georgich

Greetings.

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
notifyIcon1.Visible = false;
notifyIcon1.Dispose();
}

G
GavriKos, 2015-11-09
@GavriKos

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 question

Ask a Question

731 491 924 answers to any question