Multiple BackgroundService or IHostedServices but Only One Works

Thursday, January 22, 2026
This is a repost from my old blog. First posted in 9/2/2024.

In my worker app, I attempted to add multiple hosted services as follow:

builder.Services
    .addSingleton(HostedService1)
    .addSingleton(HostedService2)
    .addSingleton(HostedService3);

All the hosted services are added, but when the application run, only 1 is executing.


Thanks to Stephen Cleary, apparently issue with synchronous call. https://blog.stephencleary.com/2020/05/backgroundservice-gotcha-startup.html.


I ended up using Task.Run for code that executes for a long time. Inside the ExecuteAsync:

await Task.Run(async () => await LongRunningProcess());