NotifyIcon“出现”在“隐藏图标”托盘中(没有任何图标),但实际上没有显示或播放任何声音

时间:2018-07-08 12:10:13

标签: c# push-notification windows-10

if (r)
{
    NotifyIcon notification = createNotification(t, ":!: ALERT :!:",SystemIcons.Exclamation);
    // Display for 5 seconds.
    notification.ShowBalloonTip(5000);
    LastSentNotification = notification.BalloonTipText;

    // This will let the balloon close after it's 5 second timeout
    // for demonstration purposes. Comment this out to see what happens
    // when dispose is called while a balloon is still visible.
    Thread.Sleep(10000);

    // The notification should be disposed when you don't need it anymore,
    // but doing so will immediately close the balloon if it's visible.
    notification.Dispose();
}

这是我的代码的一部分,负责显示气球通知。它曾经可以正常工作,但突然停止工作。

我实际上可以看到它正在发送通知,因为在隐藏的托盘图标中有一个不可见的图标,该图标会在5秒钟内消失,并且仅在我构建程序并运行该程序后才出现,这证明它是通知。

但是,窗口根本不显示通知。它不会出现在屏幕上,也不会播放任何声音。我确实有一个错误,该错误会持续发送通知,也许当我疯狂地单击以发送通知时,我可能以某种方式关闭了程序的通知。

这是我的createNotification函数:

private NotifyIcon createNotification(string text, string title,Icon icon)

{
    var notification = new NotifyIcon()
    {
        Visible = true,
        Icon = icon,
        BalloonTipTitle = title,
        BalloonTipText = text,
    };


    return notification;
}

0 个答案:

没有答案