Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I seeing multiple Systray Icons?

Tags:

c#

systray

I've added a Notify Icon to my app, and quite often I see up to 3 copies of the notify icon in my systray. is there a reason for this?

is there a way to stop it from happening.

Often this persists after my app has closed, untill I mose over to the systray and the systray expands and collapses snd then they all disapear.

like image 500
Omar Kooheji Avatar asked Mar 17 '09 13:03

Omar Kooheji


2 Answers

Is this while you are debugging your application? if so this is because the messages that remove the icon from the system tray are only sent when the application exits normally, if it terminates because of an exception or because you terminate it from Visual Studio the icon will remain until you mouse over it.

like image 193
Richard Slater Avatar answered Oct 09 '22 15:10

Richard Slater


You can kill the icon using the parent Window's Closed event. This works in my WPF app, even when testing in Visual Studio (2010 in my case):

        parentWindow.Closing += (object sender, CancelEventArgs e) =>
        {
            notifyIcon.Visible = false;
            notifyIcon.Icon = null;
            notifyIcon.Dispose();
        };
like image 20
Ian Avatar answered Oct 09 '22 15:10

Ian