From .NET Core 2.1 onward, we can now run background tasks with hosted service.
I believe we could achieve same by adding a Service Class to service container with Singleton scope.
What are the benefits of having a hosted service over a service with singleton scope? What are the key differences?
We can inject singleton scoped service to a controller and manipulate it with every new request. However, this is not possible for hosted services.
When you register implementations of IHostedService using any of the AddHostedService extension methods - the service is registered as a singleton.