IHostedService vs. BackgroundService
There are two ways to implement background tasks in .NET, 1) implementing the IHostedService
, or 2) inheriting from BackgroundService
base class! Even though every BackgroundService
is a hosted service, the way .NET framework treats them is different, and in certain scenarios this might be problematic! In this article we take a look into some gotchas of the differences.