我有一个NotifyIcon方法,虽然我想在处理BaloonTip之前发生超时。
private void button1_Click(object sender, EventArgs e) { notifyIcon1.Visible = true; notifyIcon1.ShowBalloonTip(30000); <wait until timeout occurs> notifyIcon1.Dispose(); }
notifyIcon1.BalloonTipClosed += delegate {notifyIcon1.Dispose ();};
我宁愿隐藏NotifyIcon
而不是重新创建/处理一个新的实例。
尝试使用计时器。
应该是像…一样的东西:
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); }
和…
void TimerCallback(object notifyIcon1Obj) { lock (notifyIcon1Obj) { NotifyIcon notifyIcon1 = (NotifyIcon)notifyIcon1Obj; notifyIcon1.dispose(); notifyIcon1 = null; } }
HTH