
Handling long-running operations in a .NET Background Service
I have seen few articles around about how to execute long-running tasks in a BackgroundService and most of them do the same mistake. The code looks more or less like this: public class MyWorker : BackgroundService { protected override async Task ExecuteAsync(CancellationToken cancellationToken) { while(!cancellationToken.IsCancellationRequested) { await DoSomethingAsync(); } }...
2023, Sep 21 — 2 minute read