2013-02-21 20 views
6

我即将安排不少瓦片更新,并注意到.Clear()方法似乎不起作用。它应该'删除所有更新并恢复为其在应用程序清单中声明的​​默认内容'(MSDN)为什么TileUpdater.Clear()不能删除所有更新?

编辑:厚脸皮的MS!在该方法的文档中,它说:'注意:这种方法不会停止定期更新'

说我安排3000更新(不是我会做btw!),在调用清除计数仍然3000后。

enter image description here

同样的问题在这里问:TileUpdater.Clear() not freeing up notifications quota,唯一的建议是手动删除每个和更新之一。

我决定测试使用StopWatch类需要花费多少时间,并且花费了超过11秒18秒,最大预定更新量为4096,因此解决方案似乎有点疯狂。

enter image description here

因为我不会按小时计算的时间表提前比这几天里,可能使用一个后台任务与维持触发添加新的我会没事具有去除循环。但我仍然希望我在这里做错了事,并且有更好的解决方案。

那么,你知道为什么.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); 
     } 
    } 

回答

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像其中清除实际上意味着清除而不是重置内容。悲伤的事态,但这就是我们所有的

+0

我知道StopPeriodicUpdates,但我错过了'注意这种方法不会停止定期更新'。确实很糟糕的命名,Clear()应该是SetToDefaultTile()。多烦人。因此,它的循环是:(那么,谢谢你在这里和在Twitter伴侣的帮助:) – 2013-02-21 13:58:08

+1

不用担心..与WinRT我们回到了错误命名的COM时代:)所有那些美好的.NET公约似乎已经消失..一件好事..至少你不必调用TileUpdateFactory.CoCreateTileUpdaterForAppEx – 2013-02-21 14:04:11

相关问题