Allow requests to be cancelled.

Make workers have a CancellationTokenSource
This commit is contained in:
2025-09-01 23:26:49 +02:00
parent 6c61869e66
commit 3b8570cf57
31 changed files with 296 additions and 251 deletions

View File

@@ -9,7 +9,7 @@ public class StartNewChapterDownloadsWorker(TimeSpan? interval = null, IEnumerab
public DateTime LastExecution { get; set; } = DateTime.UnixEpoch;
public TimeSpan Interval { get; set; } = interval ?? TimeSpan.FromMinutes(1);
protected override BaseWorker[] DoWorkInternal()
protected override Task<BaseWorker[]> DoWorkInternal()
{
IQueryable<MangaConnectorId<Chapter>> mangaConnectorIds = DbContext.MangaConnectorToChapter
.Include(id => id.Obj)
@@ -19,6 +19,6 @@ public class StartNewChapterDownloadsWorker(TimeSpan? interval = null, IEnumerab
foreach (MangaConnectorId<Chapter> mangaConnectorId in mangaConnectorIds)
newWorkers.Add(new DownloadChapterFromMangaconnectorWorker(mangaConnectorId));
return newWorkers.ToArray();
return new Task<BaseWorker[]>(() => newWorkers.ToArray());
}
}