Exemple #1
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            // Run the periodic task.
            // Mutex to control web access. Only begin the process if it's free.
            List <Feed> allFeeds = DataBaseTools.GetAllFeeds();

            Deployment.Current.Dispatcher.BeginInvoke(() =>
            {
                WebTools downloader = new WebTools(new SynFeedParser());
                downloader.SingleDownloadFinished += SendToDatabase;
                try
                {
                    downloader.Download(allFeeds);
                }
                catch (WebException) { }
            });

            // Used to quickly invoke task when debugging.
#if DEBUG_AGENT
            ScheduledActionService.LaunchForTest(task.Name, System.TimeSpan.FromSeconds(60));
#endif
        }
Exemple #2
0
        /// <summary>
        /// Agent that runs a scheduled task
        /// </summary>
        /// <param name="task">
        /// The invoked task
        /// </param>
        /// <remarks>
        /// This method is called when a periodic or resource intensive task is invoked
        /// </remarks>
        protected override void OnInvoke(ScheduledTask task)
        {
            // Run the periodic task.
            List<Feed> allFeeds = DataBaseTools.GetAllFeeds();
            _remainingDownloads = allFeeds.Count;
            if (_remainingDownloads > 0)
            {
                Deployment.Current.Dispatcher.BeginInvoke(() =>
                    {
                        WebTools downloader = new WebTools(new SynFeedParser());
                        downloader.SingleDownloadFinished += SendToDatabase;
                        try
                        {
                            downloader.Download(allFeeds);
                        }
                        //TODO handle errors.
                        catch { }
                    });
            }

            // Used to quickly invoke task when debugging.
            //#if DEBUG_AGENT
            //            ScheduledActionService.LaunchForTest(task.Name, System.TimeSpan.FromSeconds(600));
            //#endif
        }