示例#1
0
 public static SubredditParser GetInstance()
 {
     if (_instance == null)
     {
         lock (_instanceLock)
             if (_instance == null)
             {
                 _instance = new SubredditParser();
             }
     }
     return(_instance);
 }
示例#2
0
        public void GetNews()
        {
            var topics = new List <RedditTopic>();

            foreach (var subredditName in _redditSettings.WatchedSubreddits)
            {
                _taskCollection.Add(Task.Factory.StartNew(() =>
                {
                    topics.AddRange(SubredditParser.GetInstance().GetSubredditNewTopics(subredditName));
                }));
            }
            Task.WaitAll(_taskCollection.ToArray());

            OnNewsUpdated.Invoke(topics);
            SettingsController.GetInstance().SaveSettings();

            Thread.Sleep(60000);
            new Thread(GetNews).Start();
        }