after the Ballon Tip of my NotifyIcon has been close the icon still stays in tray. It vanishes only when I hover it with my mouse cursor.
I have a class Notification.cs which has one component - NotifyIcon.
I call it from my Console Application as I only want to show the notification when certain conditions are fulfilled.
Some code:
how I call the notification from within my program:
Notification not = new Notification("Error occured, do this or that", "Some error", System.Windows.Forms.ToolTipIcon.Error); not.getIcon().ShowBalloonTip(1000);
the notification class:
public Notification(string baloonTipText, string baloonTipTitle, System.Windows.Forms.ToolTipIcon icon) : this() { this.icon.Visible = true; this.icon.BalloonTipText = baloonTipText; this.icon.BalloonTipTitle = baloonTipTitle; this.icon.BalloonTipIcon = icon; } public System.Windows.Forms.NotifyIcon getIcon() { return this.icon; } private void icon_BalloonTipClosed(object sender, EventArgs e) { this.icon.Visible = false; this.icon.Dispose(); }
Any ideas?
Because you're running in a console application, your
icon_BalloonTipClosed
handler will not be invoked when the balloon tip is closed (no message pump). You will need to callDispose
manually either as your application exits or set a timer (System.Threading.Timer
,System.Windows.Forms.Timer
will not work) with a timeout longer than the balloon tip's timeout. e.g.: