Background Workers
We have implemented a zero-configuration background worker system. You can use background workers for any tasks that need to happen periodically outside of the user context.
To create a new background worker, create a new class derived from TimedBackgroundWorker
. The system will discover it automatically and will register it as a hosted service. That happens in Program.CreateHostBulder
. In your new class, you can inject an ILogger if you need to, but in order to get access to your services, you will need to use the ServiceProvider
property. Then you can call ServiceProvider.GetService<IEmailService>()
for example, to get access to the email service.
Other features:
RunEveryInSeconds
An abstract property that you have to implement. It defines how often theWork
method gets called.RunOnStart
Determines whether to run theWork
method when the service starts.Work
An abstract method that you implement in your subclass.
Please note that hosted services run in the same process as the service runtime. So if service is restarted, the background worker may be interrupted. In a future release, we will have HangFire integration to deal with this issue. From more information on hosted services, see Microsoft's documentation.
Table of Contents
- Initial Setup
- Project Structure
- Configuration
- Identity
- Entity Framework
- Authorization
- Api
- User Interface
- Logging
- Email Service
- Background Workers
- Localization
- Services
- Creating a new Page
- Publishing to Azure
- Upgrading