We also document about it in our article on how to use a .NET Worker Service to run background services.
- Home
- .NET code examples
- .NET Worker Service setup to run background tasks as a Windows Service
.NET Worker Service setup to run background tasks as a Windows Service
Download a .NET Worker Service which is written in .NET 6 and configured to run background tasks.
ILogger interface and loops the task every second.
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.
Software
This is the software that will need to be installed onto your machine.
- Visual Studio 2022 17.0.4 or above. It will work with the free community version. Please note, this project will not work with VS 2019.
- .NET 6.0 SDK 6.0.101 or above. Visual Studio 2022 should already have the .NET SDK installed.
Get the application working
These are the steps to get the application working.
- Fill out the code example form. We will send you an email where you can download the code example.
You are now ready to go.
Open the project in Visual Studio
Open up RoundTheCode.WorkerServiceExample.sln in Visual Studio 2022.
ILogger instance in the hosted service.
Set up the Worker Service as a Windows Service
Watch our video where we setup and run our Worker Service as a Windows Service.
Give us your anonymous feedback regarding this page, or any other areas of the website.
Watch .NET tutorials
Subscribe to our YouTube channel
Latest code examples
C# 14: New features with code examples
Download the code example and see what's new in C# 14. From extension members to simple lambdas, learn how these features make your code cleaner and smarter.