为什么TileUpdater.Clear()没有删除所有更新?

Iri*_*son 6 c# windows-runtime

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

编辑:厚颜无耻的MS!在该方法的文档下,它说:'注意:此方法不会停止定期更新'

假设我安排了3000次更新(不是我将要做的事btw!),在调用后清除计数仍为3000.

在此输入图像描述

这里提出了同样的问题:TileUpdater.Clear()没有释放通知配额,唯一的建议是手动删除每个和一个更新.

我决定测试使用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);
        }
    }
Run Code Online (Sandbox Code Playgroud)

小智 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”实际上意味着“清除”而不是“重置内容”。情况令人悲伤,但这就是我们所拥有的一切