コード例 #1
0
        private void Initialize()
        {
            // Create Main Thread for webservice calls
            _APIThread = new APIThread();

            // Needed as we need to make sure threads are stopped on close.
            Window window = Application.Current.MainWindow;

            window.Closing += window_Closing;

            ContextColor = Brushes.Green;
        }
コード例 #2
0
        /// <summary>
        /// Reload information for the thread. This gets all the post information from the API, updates the cache in-place,
        /// and returns a new list of all the posts in the thread.
        /// </summary>
        /// <returns>A list of the posts in the thread.</returns>
        public async Task <List <Post> > GetPostsAsync()
        {
            using (Stream s = await RequestManager.Current.GetStreamAsync(new Uri("http://a.4cdn.org/" + Board.Name + "/thread/" + Number + ".json")))
            {
                DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(APIThread));

                APIThread t = await dcjs.ReadObjectAsync <APIThread>(s);

                List <Post> posts = new List <Post>();
                foreach (APIPost p in t.Posts)
                {
                    Merge(p);
                    posts.Add(Posts[p.Number]);
                }

                return(posts);
            }
        }
コード例 #3
0
 public override void Shutdown()
 {
     APIThread?.Stop();
 }