Solved

notifyIcon not disappearing after closing the program

Posted on 2007-11-16
7
1,097 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:EEssam
Comment Utility
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
Comment Utility
That's depend on where is located your notifyIcon. How and where did you create it?
0
 

Author Comment

by:EEssam
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now