public async Task CancelAsync() { isCanceled = true; PartList.ForEach(x => x.Task.Cancel()); DownloadPage.Current.activeDownloadList.Remove(this); await this.CacheFolder.DeleteAsync(); }
public void PauseOrResume() { if (IsCompleted) { return; } PartList.ForEach(p => { p.PauseOrResume(); }); IsPaused = !IsPaused; switch (IsPaused) { case true: ChineseStatus = "已暂停"; break; case false: ChineseStatus = "下载中"; break; } ; }
/// <summary> /// 视频下载 /// </summary> /// <returns></returns> private async Task Download() { #region 绑定下载进度事件 List <Task> taskList = new List <Task>(); if (this.PartList != null) { PartList.ForEach(part => { part.ReceivedProgress += Part_ReceivedProgress; Task task = part.Start(this._cancelSource.Token); taskList.Add(task); }); } #endregion List <string> downloadPartList = this.PartList.Select(part => part.StorePath).ToList(); await Task.WhenAll(taskList); }