private async Task GetChaptersImageList(CancellationToken ct) { while (!ct.IsCancellationRequested) { foreach (var chapterToDownload in ChaptersToDownload.Where(x => x.Status == ChapterToDownload.ChapterStatus.Pending)) { try { chapterToDownload.Status = ChapterToDownload.ChapterStatus.GettingImageList; if (chapterToDownload.ImagesUrls.Count < 1) { await chapterToDownload.GetImages(ct); } chapterToDownload.Status = ChapterToDownload.ChapterStatus.ReadyToDownload; } catch { chapterToDownload.Status = ChapterToDownload.ChapterStatus.Error; } } await Task.Delay(1000, ct); } }
private void SetDownloadsPending() { foreach (var chapter in ChaptersToDownload.Where( ch => ch.Status != ChapterToDownload.ChapterStatus.Complete)) { chapter.Status = ChapterToDownload.ChapterStatus.Pending; } }