Part of the reason for this behavior is that the timer used in ShowBalloonToolTip was designed to work only when the OS detects user input. That way, if you just expect the balloon to disappear and actually do nothing, it will never time out.
I believe the reasoning was that if you left your computer and returned in an hour, you would not miss any notifications.
There is a way around this, and this is to start a separate timer that switches the visibility of the icon.
For instance:
private void ShowBalloonWindow(int timeout) { if (timeout <= 0) return; int timeoutCount = 0; trayIcon.ShowBalloonTip(timeout); while (timeoutCount < timeout) { Thread.Sleep(1); timeoutCount++; } trayIcon.Visible = false; trayIcon.Visible = true; }
change
Oh yes, I put it together without thinking about how you used it. If you want to run this asynchronously, I would suggest that you put a timer in the workflow to the Invokes
method, which by default completes the trayIcon.Visible
property.
source share