private void DownloadObject(UrlItem urlItem) { this.downloadsCounter._TotalDownloads.Increment(); switch (urlItem.contentType) { case FileType.TypeEnum.PAGE: this.DownloadText(urlItem.url); break; case FileType.TypeEnum.GRAPHIC: this.DownloadGraphic(urlItem.url); break; default: break; } }
private void RunDownloadTask() { Task.Factory.StartNew(() => { UrlItem item = new UrlItem(); while (true) { while (this.urlsQueue.TryDequeue(out item)) { UrlItem newItem = item; Task.Run(() => { this.DownloadObject(newItem); }); } } }); }