Reputation: 61
I have a NotifyIcon method, although I would like the timeout to happen, before disposing of the BaloonTip.
private void button1_Click(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(30000);
<wait until timeout occurs>
notifyIcon1.Dispose();
}
Upvotes: 1
Views: 1022
Reputation: 5913
I would rather hide the NotifyIcon
instead of recreating/disposing a new instance of it.
Upvotes: 1
Reputation: 27943
notifyIcon1.BalloonTipClosed += delegate {notifyIcon1.Dispose ();};
Upvotes: 3
Reputation: 5950
Try using a timer.
Should be something like...:
private Timer taskTimer;
private NotifyIcon notifyIcon1;
private void button1_Click(object sender, EventArgs e)
{
notifyIcon1.Visible = true;
notifyIcon1.ShowBalloonTip(30000);
taskTimer = new Timer(TimerCallback, notifyIcon1, 30000, System.Threading.Timeout.Infinite);
}
and...
void TimerCallback(object notifyIcon1Obj)
{
lock (notifyIcon1Obj)
{
NotifyIcon notifyIcon1 = (NotifyIcon)notifyIcon1Obj;
notifyIcon1.dispose();
notifyIcon1 = null;
}
}
HTH
Upvotes: 0