Exemplo n.º 1
0
        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;
            }
        }
Exemplo n.º 2
0
 public Worker(IPPool ipPool, SharedWork work)
 {
     this.ipPool = ipPool;
     this.work   = work;
 }
Exemplo n.º 3
0
 public AssetDownloader(byte threads, IPPool ipPool, string host, string path)
     : this(threads, ipPool, host, null, 0, path, true, false)
 {
 }
Exemplo n.º 4
0
 public AssetDownloader(byte threads, IPPool ipPool, string host, string[] requests, string path)
     : this(threads, ipPool, host, requests, requests.Length, path, false, false)
 {
 }