Solved

notifyIcon not disappearing after closing the program

Posted on 2007-11-16
7
1,105 Views
Last Modified: 2013-12-17
Hi,

I have notifyIcon icon control and it's working fine but not it's not disappearing when I close the the program.

How can this be fixed?

Thanks.
0
Comment
Question by:EEssam
  • 3
  • 3
7 Comments
 
LVL 27

Expert Comment

by:Dabas
ID: 20302305
Hello EEssam,

Are you sure your program is actually closing? (For example, have you checked in task manager -> Processes that its process actually has closed?

Regards,

Dabas
0
 

Author Comment

by:EEssam
ID: 20302313
Yes, I'm using Application.Exit() and as soon as I move the mouse over the icon it disappears.
0
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 500 total points
ID: 20302376
you need to dispose the NotifyIcon when terminating your application:

inside your Program class, do this:
           
static class Program
{
        [STAThread]
        static void Main()
        {      
                Application.ApplicationExit +=new EventHandler(Application_ApplicationExit);
                 // other tasks
        }
 
        static void Application_ApplicationExit(object sender, EventArgs e)
        {
            yourNotifyIcon.Dispose();
        }
}

Open in new window

0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:EEssam
ID: 20302390
I got this error:

Error      1      The name 'notifyIcon' does not exist in the current context      D:\xxx\xxx\xxx\Program.cs      25      13      xxx
0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20302399
That's depend on where is located your notifyIcon. How and where did you create it?
0
 

Author Comment

by:EEssam
ID: 20302458
I have a normal C# 2.0 Application. The Program.cs is created and a default form. My notifyIcon is located in my default form created in:
Application.Run(new FormFirst());

Open in new window

0
 
LVL 55

Expert Comment

by:Jaime Olivares
ID: 20302539
better you put the notify icon in the program class.
But if you don't want, you can create a form's Closing event handle and dispose there.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question