Esempio n. 1
0
        /// <summary>
        /// Refreshes the content of all feeds that are related to this module.
        /// </summary>
        /// <remarks>Each feed is refreshed in a separate thread.</remarks>
        private void RefreshFeeds()
        {
            IList feeds = GetAllFeeds();

            foreach (Feed feed in feeds)
            {
                if (feed.UpdateTimestamp.AddMinutes(this._cacheDuration) < DateTime.Now)
                {
                    // HACK: update the updatetimestamp before anything is refreshed.
                    // This will prevent that other threads also refresh the feed.
                    feed.UpdateTimestamp = DateTime.Now;
                    base.NHSession.Update(feed);
                    base.NHSession.Flush();
                    // The feed is kind of locked now (with the updatetimestamp). Plenty
                    // of time now to refresh the feeds.
                    base.NHSession.Evict(feed);

                    if (this._backgroundRefresh)
                    {
                        FeedFetcher ff = new FeedFetcher(feed, null);
                        // Fire a separate to refresh the feed so the visitor doesn't have to wait.
                        Thread t = new Thread(new ThreadStart(ff.FetchFeed));
                        t.Priority = ThreadPriority.BelowNormal;                         // No need to rush here
                        t.Start();
                    }
                    else
                    {
                        FeedFetcher ff = new FeedFetcher(feed, base.NHSession);
                        ff.FetchFeed();
                    }
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Refreshes the content of all feeds that are related to this module.
        /// </summary>
        /// <remarks>Each feed is refreshed in a separate thread.</remarks>
        private void RefreshFeeds()
        {
            IList feeds = GetAllFeeds();
            foreach (Feed feed in feeds)
            {
                if (feed.UpdateTimestamp.AddMinutes(this._cacheDuration) < DateTime.Now)
                {
                    // HACK: update the updatetimestamp before anything is refreshed.
                    // This will prevent that other threads also refresh the feed.
                    feed.UpdateTimestamp = DateTime.Now;
                    base.NHSession.Update(feed);
                    base.NHSession.Flush();
                    // The feed is kind of locked now (with the updatetimestamp). Plenty
                    // of time now to refresh the feeds.
                    base.NHSession.Evict(feed);

                    if (this._backgroundRefresh)
                    {
                        FeedFetcher ff = new FeedFetcher(feed, null);
                        // Fire a separate to refresh the feed so the visitor doesn't have to wait.
                        Thread t = new Thread(new ThreadStart(ff.FetchFeed));
                        t.Priority = ThreadPriority.BelowNormal; // No need to rush here
                        t.Start();
                    }
                    else
                    {
                        FeedFetcher ff = new FeedFetcher(feed, base.NHSession);
                        ff.FetchFeed();
                    }
                }
            }
        }