Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why doesn't TileUpdater.Clear() remove all updates?

I'm about to schedule quite a few tile updates, and noticed that the .Clear() method doesn't seem to work. It should 'Removes all updates and reverts to its default content as declared in the app's manifest'(MSDN)

EDIT: Cheeky MS! Under the documentation for that method it says: 'Note: This method does not stop periodic updates'

Say I schedule 3000 updates (not what I will be doing btw!), after calling clear the count is still 3000.

enter image description here

The same question was asked here: TileUpdater.Clear() not freeing up notifications quota , and the only recommendation was to manually remove each and one of the updates.

I decided to test how much time that would take by using the StopWatch class, and it took a bit over 11 seconds, 18 seconds with the max amount of scheduled updates at 4096,- so that solution seems a bit crazy.

enter image description here

Since I wont schedule more than a few days ahead on hourly basis and probably use a background task with a maintenance trigger to add new ones I'll be fine with the removal-loop. But I still hope I'm doing something wrong here and that there is a better solution.

So, do you know why .Clear() doesn't work, and what would the best alternative be?

Here is the code if you want to give this a try:

 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);
        }
    }
like image 430
Iris Classon Avatar asked Feb 21 '13 13:02

Iris Classon


1 Answers

Iris,

Clear only clears the changes to tile.

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

StopPeriodicUpdate only cancels scheduled updates but does not remove them. http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.notifications.tileupdater.stopperiodicupdate.aspx

Bottom line is - functionality isn't there. Documentation is not clear / .NET like where Clear would actually mean Clear and not reset content. Sad state of affairs but that's all we have

like image 138
Hermit Dave Avatar answered Oct 18 '22 17:10

Hermit Dave