.NET Core worker services can be really useful every time we need to perform a repetitive or background-running operation. In more detail, they can be used in the application layer to enable asynchronous operations and handle the events of an event-based architecture. If every time you need to publish or listen for a message, you need to refresh data based on a schedule, or your application needs to queue a background work item, then you should probably use a worker service. Furthermore, with worker services, it is possible to run multiple background tasks on the same server without consuming a lot of resources.
The foundation of worker services in .NET Core is the IHostedService interface. The out-of-the-box worker service template can be used as a guideline to start implementing our worker service project. More importantly, the IHostedService interface is implemented by a BackgroundService class, which is the base class we should extend to implement our worker service.