Exemple #1
0
        /// <summary>
        ///
        /// </summary>
        public void LoadNews()
        {
            try
            {
                HttpWebRequest request = WebRequest.CreateHttp(Formula1Url);
                request.BeginGetResponse(token =>
                {
                    using (var response = request.EndGetResponse(token) as HttpWebResponse)
                        if (response != null)
                        {
                            using (Stream stream = response.GetResponseStream())
                            {
                                using (var sReader = new StreamReader(stream))
                                {
                                    string feedContent = sReader.ReadToEnd();
                                    var rssResult      = FeedReader.LoadFeed(feedContent);

                                    News = new ObservableCollection <RssItem>();
                                    foreach (var item in rssResult.Items)
                                    {
                                        News.Add(item);
                                    }
                                }
                            }
                        }
                }, null);
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
        }