dotnet-core-background-jobs

0

Описание

This is a .Net Core project with an example of background jobs for powered by Quartz

Языки

  • C#100%
README.md

Quartz jobs with scoped context

When creating some scheduled jobs we need to think properly which type for services and context we should use.

Scheduled jobs should be singletones as their lifetime is the same as the lifetime of the entire application. Even if we configure a service with "IServiceCollection.AddHostedService", we should know the service will be configured as singleton. But the context used there should not be singleton, but should have scoped lifetime. In that case we should not use dependency injection mechanism, but should use scoped context inside methods in singleton services, which are injected into singleton jobs.

reference

In that case we could avoid issues with data reader not being closed.