private async Task StartSiteSpecificDownloaderAsync(QueueListItem queueListItem, PauseToken pt, CancellationToken ct) { IBlog blog = queueListItem.Blog; blog.Dirty = true; ProgressThrottler <DownloadProgress> progress = SetupThrottledQueueListProgress(queueListItem); ICrawler crawler = null; try { crawler = _crawlerFactory.GetCrawler(blog, progress, pt, ct); await crawler.CrawlAsync(); blog.UpdateProgress(true); } finally { crawler?.Dispose(); } Monitor.Enter(_lockObject); QueueOnDispatcher.CheckBeginInvokeOnUI(() => _crawlerService.RemoveActiveItem(queueListItem)); Monitor.Exit(_lockObject); if (!ct.IsCancellationRequested) { Monitor.Enter(_lockObject); QueueOnDispatcher.CheckBeginInvokeOnUI(() => QueueManager.RemoveItem(queueListItem)); Monitor.Exit(_lockObject); } }
private async Task StartSiteSpecificDownloaderAsync(QueueListItem queueListItem, PauseToken pt, CancellationToken ct) { IBlog blog = queueListItem.Blog; blog.Dirty = true; ProgressThrottler <DownloadProgress> progress = SetupThrottledQueueListProgress(queueListItem); ICrawler crawler = null; try { crawler = _crawlerFactory.GetCrawler(blog, progress, pt, ct); queueListItem.InterruptionRequested += crawler.InterruptionRequestedEventHandler; await crawler.CrawlAsync(); blog.UpdateProgress(false); } catch (Exception e) { if (!ct.IsCancellationRequested) { Logger.Error("CrawlerController.StartSiteSpecificDownloaderAsync: {0}", e); } } finally { if (crawler != null) { queueListItem.InterruptionRequested -= crawler.InterruptionRequestedEventHandler; } crawler?.Dispose(); } Monitor.Enter(_lockObject); QueueOnDispatcher.CheckBeginInvokeOnUI(() => _crawlerService.RemoveActiveItem(queueListItem)); Monitor.Exit(_lockObject); if (!ct.IsCancellationRequested) { Monitor.Enter(_lockObject); QueueOnDispatcher.CheckBeginInvokeOnUI(() => QueueManager.RemoveItem(queueListItem)); Monitor.Exit(_lockObject); } }
private async Task StartSiteSpecificDownloader(QueueListItem queueListItem, CancellationToken ct, PauseToken pt) { IBlog blog = queueListItem.Blog; blog.Dirty = true; ProgressThrottler <DownloadProgress> progress = SetupThrottledQueueListProgress(queueListItem); ICrawler crawler = CrawlerFactory.GetCrawler(blog.BlogType, ct, pt, progress, shellService, crawlerService, blog); await crawler.Crawl(); if (ct.IsCancellationRequested) { Monitor.Enter(lockObject); QueueOnDispatcher.CheckBeginInvokeOnUI(() => crawlerService.RemoveActiveItem(queueListItem)); Monitor.Exit(lockObject); } else { Monitor.Enter(lockObject); QueueOnDispatcher.CheckBeginInvokeOnUI(() => QueueManager.RemoveItem(queueListItem)); QueueOnDispatcher.CheckBeginInvokeOnUI(() => crawlerService.RemoveActiveItem(queueListItem)); Monitor.Exit(lockObject); } }