public void InitDownload() { // 停止正在进行的下载 PauseDownload(); // 置空当前处理对象 downloadTaskList.Clear(); downloadSpeed = null; downloadProcess = null; downloadCountProcess = null; unzipProcess = null; downloadResult = null; curDownloadTask = null; curUnzipTask = null; downloadedCount = 0; IsPause = false; }
public bool CreateDownloadTask(string _reomteUrl, string _localFolder, string _fileName, string _fileSuffix, long _fileSize, bool _isZipFile = true, long?_unZipSize = null) { if (downloadTaskList.ContainsKey(_reomteUrl)) { return(false); } DownloadTask task = new DownloadTask(_reomteUrl, _localFolder, _fileName, _fileSuffix, _fileSize, _isZipFile, _unZipSize); task.OnHandleError = HotterError; task.OnDownloadComplete = BeginDownload; task.OnUnzipComplete = BeginUnzip; task.OnDownloadSpeed = DownloadSpeed; task.OnDownloadProcess = DownloadProcess; task.OnUnzipProcess = UnzipProcess; downloadTaskList.Add(_reomteUrl, task); return(true); }
private void BeginUnzip() { ABCheck.Instance.EnterInvoke(() => { curUnzipTask = null; foreach (DownloadTask task in downloadTaskList.Values) { if (task.IsNeedUnzip) { curUnzipTask = task; curUnzipTask.UnZip(); break; } } // 解压完成后,整个下载就结束了 if (null == curUnzipTask) { if (null != downloadResult) { downloadResult(true, null); } } }); }
public void BeginDownload() { ABCheck.Instance.EnterInvoke(() => { downloadedCount++; curDownloadTask = null; downloadprocess = -1; unzipprocess = -1; DownloadCountProcess(downloadedCount); foreach (var task in downloadTaskList.Values) { if (task.DownloadProcess < 1) { curDownloadTask = task; curDownloadTask.Start(); break; } } if (null == curDownloadTask) { BeginUnzip(); } }); }