public static void RemoveQuestionsAndSave(IList <string> keysToDelete) { // Remove from questions-list and add to read-questions-list. foreach (string key in keysToDelete) { if (questionsCollection.Remove(key)) { ReadListManager.AddReadQuestion(key); } else { // Removing a question that was not in the questions-list. Debugger.Break(); } } // Only save if at least one question was deleted. if (keysToDelete.Count > 0) { ReadListManager.LimitTo450AndSave(); // Do not wait until questions-save is completed. var saveOperation = QuestionsManager.SaveAsync(); // And refresh tile and badge. FeedManager.UpdateTileAndBadge(); } }
// Notice that tile update, badge update and saveing only occurs if at least one questions is removed. public static IAsyncAction RemoveReadQuestionsUpdateTileAndBadgeAndSaveAsync() { return(AsyncInfo.Run(async(cancellationToken) => { uint removedQuestions = await RemoveQuestionsInReadList(); // Only save if at least one question was deleted. if (removedQuestions > 0) { await QuestionsManager.SaveAsync(); FeedManager.UpdateTileAndBadge(); } })); }