NotifyIcon double image

I am using the NotifyIcon class outside of a windows form. It works fine, but when I try to swap out the image, I get two images, the original and the new one...the original will go away after a second or two...but it is noticeable. Is there anything I can do to solve thisdouble vision problem?

Here is a code snippet of what I am doing:

NotifyIcon nti = new NotifyIcon();

nti.Icon = ((System.Drawing.Icon)(MainApp.Properties.Resources.services));
nti.Visible = true;

// Here is the requested change.

nti.Icon = ((System.Drawing.Icon)(MainApp.Properties.Resources.servicestopped));

advTHANKSance

[1745 byte] By [OmegaMan] at [2007-12-22]
# 1

Hi OmegaMan,

I set the interval of the timer to 1 sec, and use the following code to swap the icon image.



private void timer1_tick(object sender, EventArgs e)
{
if (interchange == true)
{
this.appNotifyIcon.Icon = new Icon("app1.ico");
interchange = false;
}
else
{
this.appNotifyIcon.Icon = new Icon("app2.ico");
interchange = true;
}
}

but it works fine here, i can't reproduce the problem. I tend to consider that it's the responsibility of the system tray instead of your app. btw, do you have this situation everytime?

gqlu at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...
# 2
I will have to try this on other systems, that is a good suggestion. Its possible that my wacked out resolution on my new laptop (1920x1200) could be a cause...maybe. But I will try this on other machines, thanks.

I have noticed similar problems with other applications, when they don't catch an excpetion and their tray icon stays alive after the programs dies. Subsequently restaring the app has a double icon momentarily.

This icon isn't one that flashes, it is meant to convey state and only changes infrequently. And yes it does happen frequently and is easily reproducable.

I will have to investigate further, by creating a console application and testing different scenarios. I will post any findings or results.

Thanks!

OmegaMan at 2007-8-30 > top of Msdn Tech,Windows Forms,Windows Forms General...