[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

notifyIcon not disappearing after closing the program

Posted on 2007-11-16
7
Medium Priority
?
1,131 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

649 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