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.
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.
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);
}
}
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With