2013-02-21 32 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

相關問題