Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/299.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Toast通知仅在应用程序被激活时弹出_C#_Javascript_Windows 8_Windows Runtime_Windows Store Apps - Fatal编程技术网

C# Toast通知仅在应用程序被激活时弹出

C# Toast通知仅在应用程序被激活时弹出,c#,javascript,windows-8,windows-runtime,windows-store-apps,C#,Javascript,Windows 8,Windows Runtime,Windows Store Apps,我的toast通知有这个问题,我的应用程序只有在激活时才会显示toast通知(即:当我使用它时) 以下是我的toast通知代码: private void ShowToastNotification(string text) { var xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01); xml.GetElementsByTagName

我的toast通知有这个问题,我的应用程序只有在激活时才会显示toast通知(即:当我使用它时)

以下是我的toast通知代码:

    private void ShowToastNotification(string text)
    {
        var xml = ToastNotificationManager.GetTemplateContent(ToastTemplateType.ToastText01);

        xml.GetElementsByTagName("text")[0].AppendChild(xml.CreateTextNode(text));

        ToastNotificationManager.CreateToastNotifier().Show(new ToastNotification(xml));
    }
我的应用程序只是一个提醒应用程序,用户设置时间和文本,当该应用程序显示该文本的toast通知时。 我只是使用一个循环计时器,每5秒钟检查一次提醒

    public MainPage()
    {
        this.InitializeComponent();

        DispatcherTimer d = new DispatcherTimer();
        d.Interval = new TimeSpan(0,0,5);
        d.Start();
        d.Tick += delegate
        {
            CHECK();
        };
    }

    private void CHECK()
    {
        foreach (REMINDER_CLASS er in REMINDERS)
        {
            if (DateTime.Now.ToString("MM/dd/yyyy hh:mm:tt") == er.DateTime)
            {
                ShowToastNotification(er.Reminder);

                break;
            }
        }
    }
因此,当时间到来时,它不会显示toast通知,当我单击应用程序时,它会显示通知,就像它被挂起一样,当我打开它时,它会恢复

顺便说一句,我在appxmanifest中将Toast-capable设置为yes,并在声明中添加了类型为:Timer和System-Event的后台任务

解决方案可能是不允许应用程序睡眠或挂起,但我不知道如何阻止应用程序挂起。
另一个解决方案可能是后台任务,如果您能为我提供一个很好的简单的后台任务资源,我将不胜感激。

根据您共享的详细信息和代码,您应该研究一下这个类。Windows将在指定时间为某个应用程序显示计划的祝酒,即使该应用程序未运行或已挂起。

根据您共享的详细信息和代码,您应该查看该类。Windows将在指定的时间为某个应用程序显示计划的祝酒,即使该应用程序未运行或已挂起。

我认为这比需要的更难:)如果使用它,它将正常工作,并且不需要任何后台任务


如果你确实想处理背景任务,白皮书可能会有所帮助。

我认为你让这件事变得比需要的更难:)如果你使用它,它只会起作用,你不需要任何背景任务


如果您确实想处理后台任务,白皮书可能会有所帮助。

非常感谢,它确实是解决方案!非常感谢,这确实是解决办法!非常感谢,这确实是解决办法!非常感谢,这确实是解决办法!