예제 #1
0
        /// <summary>
        /// 下载结束后重新尝试下载失败的图片(异步)
        /// </summary>
        /// <returns>Task</returns>
        public static async Task ReTryAsync()
        {
            Debug.WriteLine("成功:" + "开始Retry");


            List <ImageModel> failsList = new List <ImageModel>();

            DownloadFailImages.ForEach(img => failsList.Add(img));
            DownloadFailImages.Clear();
            DelegateCommands.SetImageDownloadFailCountCommand?.Invoke(DownloadFailImages.Count());
            await downloadImagesParallel(failsList);

            if (UnAvailablePages.Count != 0)
            {
                List <ImagePageModel> failImagePages = new List <ImagePageModel>();
                UnAvailablePages.ForEach(page => failImagePages.Add(page));
                UnAvailablePages.Clear();
                DelegateCommands.SetUnavailableImagePageCountCommand?.Invoke(UnAvailablePages.Count());
                List <ImageModel> imageModels = await getAllImageUrls(failImagePages);
                await downloadImagesParallel(imageModels);
            }

            SoundPlayer.PlayCompleteness();
            new Window_FinishResult().Show();
        }
예제 #2
0
 public static async Task StartDownload(ObservableCollection <TaskItem> taskItems)
 {
     DownloadFailImages.Clear();
     DownloadFinishImages.Clear();
     UnAvailablePages.Clear();
     for (int i = 0; i < taskItems.Count; i++)
     {
         await downloadATask(taskItems[i]);
     }
     SoundPlayer.PlayCompleteness();
     new Window_FinishResult().Show();
 }