// 添加任务 private static void AddJob(DownloadJob job) { job.DownloadCompleted += Job_DownloadCompleted; job.DownloadCancel += Job_DownloadCancel; DownloadJobs.Add(job); Downloader.Add(job); }
// 下载被取消时 private static async void Job_DownloadCancel(DownloadJob job) { job.DownloadCompleted -= Job_DownloadCompleted; job.DownloadCancel -= Job_DownloadCancel; await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync( CoreDispatcherPriority.Normal, () => { DownloadJobs.Remove(job); FinishedJobs.Add(job); }); }