When is IHostedService / BackgroundService used and how DI works?
there
- Use IHostedService or BackgroundService for tasks that run in the
background.
- Services are injected via constructor. Scoped services must use
IServiceScopeFactory.
there
background.
IServiceScopeFactory.