Search code examples
.netwinformsballoon-tip

Why are balloontips delayed when the screen is locked?


An application I've written displays a balloon tip (using NotifyIcon.ShowBalloonTip()) when a certain event happens. This can also happen while the system is locked.

In this case the balloon tip does not immediatels display after unlocking it or not at all - both cases would be fine and make sense. However, it displays after some time - sometimes more than half an hour.

This behaviour is very annoying and I'd like to know if there's a way to prevent it except checking if the screen is locked before showing the balloontip.


Solution

  • Taskbar notifications (this is the official terminology) have tricky logic associated with them.

    1. Notifications are displayed either immediately, or after resuming from certain states, such as when the PC is locked (or playing a fullscreen game):

      http://blogs.msdn.com/b/oldnewthing/archive/2005/01/10/349894.aspx

    2. In Vista and later, notifications are only displayed for 9 seconds, and this is not adjustable:

      http://blogs.msdn.com/b/oldnewthing/archive/2011/05/18/10165605.aspx

    3. Notification balloons do not show up at all for the first hour a user is logged on for the first time:

      http://msdn.microsoft.com/en-us/library/windows/desktop/ee330740(v=vs.85).aspx

    Most importantly, Windows does not guarantee that the user will see them. In the Windows UX Guidelines, they state:

    Don't assume that users will see your notifications. Users won't see them when:

    • They are immersed in their work.
    • They aren't paying attention.
    • They away from their computer.
    • They are running a full-screen application.
    • Their administrator has turned off all notifications for their computer.

    It also states that the user might not see the messages in time either, in which case you should unqueue your messages when they are no longer relevant. You can do this by calling ShowBalloonTip(0, String.Empty, String.Empty, ToolTipIcon.None). I think doing this is your best bet to prevent irrelevant balloons from being shown.