Worker Services in .NET Core (Background Services)

Опубликовано: 06 Март 2025
на канале: Shiv Kumar
34,755
715

Background tasks with hosted services in ASP.NET Core. In ASP.NET Core, background tasks can be implemented as hosted services. A hosted service is a class with background task logic that implements the IHostedService interface. BackgroundService is a base class for implementing a long running IHostedService.

Chapter Markers
00:00 Introduction
00:57 What is a Hosted Service
04:02 Starting with the code - Creating yout first Worker Service
04:41 Inroducing the Project Template and the parts an pirces
07:45 Explanation of the StartAsync, ExecuteAsync and StopAsync methods
11:40 Building our own Background service by Implementing IHostedService
22:37 Things to think about when deciding to use Worker Services
26:22 Building a RabbitMQ Subscriber Worker Service
42:52 Converting a Worker Service to a Windows Service
46:38 Registering the Worker Service as a Windows Service
52:45 Adding the Worker Service to an ASP.NET Core application
53:17 Stopping and Deleting the Windows Service
53:50 Adding an ASP.NET Core Web API project to the Solution
54:20 Registering and Testing the Worker Service

The source code for solution presented in this video can be found here:
https://github.com/matlus/WorkerServi...