private void Start() { if (queue.Count > 0) { currentTask = queue.Dequeue(); currentTask.Start(); } }
/// <summary> /// 如果报错 上层代码调用clear 再创建新的 /// </summary> public void Dispose() { while (queue.Count > 0) { DownLoadTask task = queue.Dequeue(); task.Dispose(); } queue = null; }
public void DownLoadFiles(UrlDiskPath[] paths, Action complete, Action <float> progress, Action <string> error) { this.complete = complete; this.progress = progress; this.error = error; this.taskCount = paths.Length; for (int i = 0; i < paths.Length; i++) { DownLoadTask task = new DownLoadTask(i, "Task" + i, paths[i], TaskProgress, TaskComplete, TaskError); queue.Enqueue(task); } Start(); }