public AssetDownloader(byte threads, IPPool ipPool, string host, IEnumerable <string> requests, int length, string path, bool keepalive, bool headersOnly) { this.threads = threads; this.keepalive = keepalive; Queue <string> q; if (requests != null) { q = new Queue <string>(requests); } else { q = new Queue <string>(); } var work = this.work = new SharedWork() { host = host, locations = q, length = length, index = 0, path = path, keepalive = keepalive, headersOnly = headersOnly, abort = false, waiter = keepalive ? new ManualResetEvent(true) : null }; workers = new Worker[threads]; for (var i = 0; i < threads; i++) { var worker = workers[i] = new Worker(ipPool, work); worker.BytesDownloaded += worker_BytesDownloaded; worker.Complete += worker_Complete; worker.Error += worker_Error; worker.RequestComplete += worker_RequestComplete; } }
public Worker(IPPool ipPool, SharedWork work) { this.ipPool = ipPool; this.work = work; }