public Subreddit(string name, RedditService service) { Name = name; Service = service; _urlBuilder = new StringBuilder(); _serializer = new JsonSerializer(); }
private async void StartLoadingSubreddit() { try { var reddit = new RedditService(); var subreddit = await reddit.GetSubredditAsync("Terraria"); _resourceManager = new ResourceManager("Cache"); _resourceManager.Start(); _postsLeftToLoad = 20; var postEnumerator = subreddit.EnumeratePosts(10000, 25).GetEnumerator(); int c = 0; while (_processPosts) { while (_postsLeftToLoad > 0 && postEnumerator.MoveNext() && _processPosts) { var post = postEnumerator.Current; _postsLeftToLoad--; c++; //if (!post.HasThumbnail) continue; var graphic = new PostGraphicsObject(post, GraphicsDevice, _resourceManager); lock (_postGraphics) _postGraphics.Add(graphic); DoObjectLayout(); } Thread.Sleep(10); } Console.WriteLine("Posts iterated: " + c); } catch (Exception exc) { Console.WriteLine("Loading subreddit failed: " + exc); } }