public DownloadResults Download() { TickableProgressTick tickableProgress = new TickableProgressTick(_progressHost, _urlsToDownload.Count); Hashtable workItems = new Hashtable(); foreach (string url in _urlsToDownload.Keys) { DownloadWorkItem workItem = new DownloadWorkItem(url, (int)_urlsToDownload[url], tickableProgress); workItems.Add(url, workItem); _downloadQueue.Enqueue(workItem); } ParallelExecution execution = new ParallelExecution(new ThreadStart(DoWork), _threadCount); execution.Execute(); DownloadResults results = new DownloadResults(); foreach (string url in workItems.Keys) { results.AddResult(url, ((DownloadWorkItem)workItems[url]).FilePath); } return(results); }
public DownloadResults Download() { TickableProgressTick tickableProgress = new TickableProgressTick(_progressHost, _urlsToDownload.Count); Hashtable workItems = new Hashtable(); foreach (string url in _urlsToDownload.Keys) { DownloadWorkItem workItem = new DownloadWorkItem(url, (int)_urlsToDownload[url], tickableProgress); workItems.Add(url, workItem); _downloadQueue.Enqueue(workItem); } ParallelExecution execution = new ParallelExecution(new ThreadStart(DoWork), _threadCount); execution.Execute(); DownloadResults results = new DownloadResults(); foreach (string url in workItems.Keys) { results.AddResult(url, ((DownloadWorkItem)workItems[url]).FilePath); } return results; }