Solved

notifyIcon not disappearing after closing the program

Posted on 2007-11-16
7
1,111 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Converting PHP triple des decrypt to c# 9 152
PowerShell: Adding ToGB to a script 4 66
asp.net repeater 2 31
Need a quick overview of Selenium testing 2 32
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:…
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…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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