Example #1
0
        static int Main(string[] args)
        {
            const string downloadFolder = @"d:\Data\Downloads";
            //var dt = new DownloadTask(downloadFolder, new Uri("https://www.edsm.net/dump/systemsWithCoordinates.json"));
            //var task = Task.Run<FileInfo>(async () => await dt.DownloadAsync());
            //task.Wait();
            //var fi = task.Result;

            //dt = new DownloadTask(downloadFolder, new Uri("https://www.edsm.net/dump/stations.json"));
            //task = Task.Run<FileInfo>(async () => await dt.DownloadAsync());
            //task.Wait();
            //fi = task.Result;

            var dt   = new DownloadTask(downloadFolder, new Uri("https://www.edsm.net/dump/bodies.json"));
            var task = Task.Run <FileInfo>(async() => await dt.DownloadAsync());

            task.Wait();
            var fi = task.Result;

            return(0);
        }
Example #2
0
        static void Main(string[] args)
        {
            DownloadTask task = new DownloadTask("http://7dx.pc6.com/xjq5/image2pdf41501.zip", @"D:\image2pdf41501.zip");

            task.Start();
            while (true)
            {
                if (Console.ReadKey().Key == ConsoleKey.S)
                {
                    task.Stop();
                }
                if (Console.ReadKey().Key == ConsoleKey.R)
                {
                    task.Start();
                }
                if (Console.ReadKey().Key == ConsoleKey.Escape)
                {
                    break;
                }
            }
        }
Example #3
0
 private void button_Stop_Click(object sender, EventArgs e)
 {
     if (downloadTask != null)
     {
         if (downloadTask.Config.SupportResume)
         {
             downloadTask.SetStop();
             updateProgressThread.Abort();
             downloadTask = null;
         }
         else
         {
             ModleForm modileForm = new ModleForm();
             if (modileForm.ShowDialog(this) == DialogResult.Yes)
             {
                 downloadTask.SetStop();
                 updateProgressThread.Abort();
                 downloadTask = null;
             }
             else
             {
                 return;
             }
         }
     }
     button_Start.Enabled    = true;
     button_Stop.Enabled     = false;
     button_AddIP.Enabled    = true;
     button_DeleteIP.Enabled = true;
     textBox_AddIP.Enabled   = true;
     textBox_Path.Enabled    = true;
     textBox_Url.ReadOnly    = false;
     checkBox_Prox.Enabled   = true;
     if (!checkBox_Prox.Checked)
     {
         textBox_Threads.Enabled = true;
     }
 }
Example #4
0
        private string Referer;//重定向的源地址

        public HttpDownload(DownloadTask downloadTask, int currentThreadIndex)
            : base(downloadTask, currentThreadIndex)
        {
            Referer = null;
        }
Example #5
0
 public DownloadBase(DownloadTask downloadTask, int currentThreadIndex)
 {
     this.downloadTask  = downloadTask;
     CurrentThreadIndex = currentThreadIndex;
     BufferSize         = 5120;//每次最多接收5KB
 }