ForumSurfer.Data.Feed.UpdateAll C# (CSharp) Method

UpdateAll() public static method

public static UpdateAll ( int retentionDays ) : void
retentionDays int
return void
        public static void UpdateAll(int retentionDays)
        {
            List<Feed> feeds = LoadAll();
            HashSet<Uri> existingArticles = new HashSet<Uri>();
            foreach(Feed f in feeds)
            {
                foreach(Article a in f.Articles)
                {
                    existingArticles.Add(a.Location);
                }
            }
            List<Task> TaskList = new List<Task>();
            foreach (Feed feed in feeds)
            {
                var LastTask = new Task(() => {
                    feed.Articles.Clear();
                    try
                    {
                        feed.UpdateFromUri(false, retentionDays);
                    }
                    catch(Exception e)
                    {
                        //TODO: log error somewhere
                        Debug.Print(e.Message);
                    }
                });
                LastTask.Start();
                TaskList.Add(LastTask);
            }
            Task.WaitAll(TaskList.ToArray());
            foreach(Feed feed in feeds)
            {
                foreach (Model.Article a in feed.Articles)
                {
                    if(!existingArticles.Contains(a.Location))
                    {
                        Article art = new Article(a);
                        art.Save();
                    }
                }
                feed.Save();
            }
        }