6

我即将安排相当多的磁贴更新,并注意到 .Clear() 方法似乎不起作用。它应该“删除所有更新并恢复到应用程序清单中声明的​​默认内容” (MSDN)

编辑:厚脸皮的女士!在该方法的文档下,它说:“注意:此方法不会停止定期更新”

假设我安排了 3000 次更新(顺便说一句,我不会这样做!),在调用 clear 之后计数仍然是 3000。

在此处输入图像描述

此处提出了相同的问题:TileUpdater.Clear() not freeing up notifications quota,唯一的建议是手动删除每个更新。

我决定通过使用 StopWatch 类来测试需要多少时间,它花费了 11 秒多一点,18 秒的最大计划更新量为 4096,所以这个解决方案似乎有点疯狂。

在此处输入图像描述

由于我不会按小时安排超过几天的时间,并且可能会使用带有维护触发器的后台任务来添加新任务,因此我可以使用删除循环。但我仍然希望我在这里做错了什么并且有更好的解决方案。

那么,你知道为什么 .Clear() 不起作用,最好的选择是什么?

如果您想尝试一下,这是代码:

 private void Button_Click_1(object sender, RoutedEventArgs e)
    {

        var updater = TileUpdateManager.CreateTileUpdaterForApplication();
        updater.Clear();
        var test = updater.GetScheduledTileNotifications();

        var stopWatch = new Stopwatch();
        stopWatch.Start();
        foreach (var update in test)
        {
            updater.RemoveFromSchedule(update);
        }
        stopWatch.Stop();
        var time = stopWatch.Elapsed;

        notify.Text = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
            time.Hours, time.Minutes, time.Seconds,
            time.Milliseconds / 10);

        for (int i = 0; i < 4096; i++)
        {
            var wide = TileContentFactory.CreateTileWideText09();
            var square = TileContentFactory.CreateTileSquareText04();
            wide.TextHeading.Text = "The heading";

            wide.TextBodyWrap.Text = "The body text for notification: " + i;
            square.TextBodyWrap.Text = "The body text for notification: " + i;

            wide.SquareContent = square;

            var tileNotification = new ScheduledTileNotification(wide.GetXml(), DateTime.Now.AddMinutes(i + 1));
            updater.AddToSchedule(tileNotification);
        }
    }
4

1 回答 1

1

虹膜,

清除仅清除对磁贴的更改。

http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.clear.aspx

StopPeriodicUpdate 仅取消计划的更新,但不会删除它们。 http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.stopperiodicupdate.aspx

底线是 - 功能不存在。文档不清楚/.NET 就像 Clear 实际上意味着清除而不是重置内容一样。可悲的事态,但这就是我们所拥有的一切

于 2013-02-21T13:52:35.540 回答