private async void DownloadProgress() { downloader files = new downloader(); files.BuildDownload("http://www.baibaoblog.cn:81/Asset/Assets.zip", Directory.GetCurrentDirectory() + @"\SquareMinecraftLauncherDownload\Asset\Assets.zip"); files.StartDownload(); await Task.Factory.StartNew(() => { while (true) { int end = 0; Speed = files.intermation.Speed; Progress = files.intermation.Progress; if (files.intermation.StatusId == -1) { end++; } if (files.intermation.Progress == 100) { end++; } if (end == 1) { EndDownload = 1; return; } Thread.Sleep(2000); } }); }
private async void DownloadProgress() { List <downloader> files = new List <downloader>(); for (int i = 0; i < 5; i++) { MCDownload download = AssignedDownload(); if (download != null) { downloader fileDownloader = new downloader(); fileDownloader.BuildDownload(download.Url, download.path); fileDownloader.StartDownload(); files.Add(fileDownloader); } } if (files.Count == 0) { Progress = 100; DuckEndDownload = download.Length; return; } await Task.Factory.StartNew(() => { while (true) { int end = 0; for (int i = 0; i < files.Count; i++) { Speed += files[i].intermation.Speed; if (files[i].intermation.StatusId == -1) { end++; } if (files[i].intermation.Progress == 100) { end++; } } if (end >= files.Count) { DuckEndDownload += files.Count; EndDownload += files.Count; Speed = 1; Progress += 50 / (double)(download.Length) * files.Count; DownloadProgress();//递归 return; } Thread.Sleep(200); } }); }