Download a .NET Worker Service which is written in .NET 6 and configured to run background tasks.
The code has a hosted service example set up which outputs the current time to the ILogger
interface and loops the task every second.
Download a .NET Worker Service which is written in .NET 6 and configured to run background tasks.
The code has a hosted service example set up which outputs the current time to the ILogger
interface and loops the task every second.
The project also has the Microsoft.Extensions.Hosting.WindowsServices
NuGet package installed. This provides an AddWindowsService
extension method that allows us to run our Worker Service as a Windows Service.
This is the software that will need to be installed onto your machine.
These are the steps to get the application working.
You are now ready to go.
Open up RoundTheCode.WorkerServiceExample.sln
in Visual Studio 2022.
Start the project in Visual Studio.
The hosted services will start once the project has been launched. See the console application as it sends information through the ILogger
instance in the hosted service.
Watch our video where we setup and run our Worker Service as a Windows Service.
We also document about it in our article on how to use a .NET Worker Service to run background services.
Learn Blazor WebAssembly with our online courses