コード例 #1
0
        public override void DownloadAll(IEnumerable<Uri> uris, DirectoryInfo output)
        {
            var poolName = string.Format("downloads to {0}", output.Name);

            var pool = new CustomThreadPool(poolName)
            {
                MinThreads = 1,
                MaxThreads = 4
            };

            pool.AfterWorkItem += ItemCompleted;

            foreach (Uri uri in uris)
            {
                var workItem = new DownloadItem(DownloadOne, uri, output);
                pool.AddWorkItem(workItem);
            }

            while(pool.WorkingThreads > 0)
            {}

            InvokeFinished();
        }