skip to Main Content

Using Task.Run vs BackgroundService in ASP.NET

I have this simple minimal API: var builder = WebApplication.CreateBuilder(args); // my long running process <---- builder.Services.AddHostedService<MyBackgroundService>(); var app = builder.Build(); app.MapGet("/", () => "Hello World!"); app.Run(); And here is MyBackgroundService: public class MyBackgroundService : BackgroundService { protected override async…

VIEW QUESTION
Back To Top
Search