?
Solved

notifyIcon not disappearing after closing the program

Posted on 2007-11-16
7
Medium Priority
?
1,124 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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
Stack Overflow Podcast - Frustrating Miracles

In this podcast, Stack Overflow interviewed Linux Academy CEO/Founder, Anthony James, and got his developer story!

"Follow your passion, be prepared to work hard and sacrifice, and, above all, don't let anyone limit your dreams."  - Donovan Bailey

 

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

Quick Start: DOCKER

Sometimes you just need a Quick Start on a topic in order to begin using it.. this is just what you need to know to get up and running with Docker!

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

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