Skip to content

Latest commit

 

History

History

workers

README.md

languages
csharp
products
dotnet
page_type sample
name Worker Services in .NET
urlFragment csharp-workers-fundamentals
description Several .NET 6 worker service applications that contain sample source code for interacting with IHostedService, and BackgroundService.

Worker Services in .NET sample source code

There are six sample source code projects in this collection of samples. The samples are written in C# and the content of the related docs is covered in Worker Services in .NET articles. In addition to an overview, there are in-depth articles discussing queue service implementations, BackgroundService scenarios, custom IHostedService implementations, Windows Services interop with the BackgroundService, and even deploying a worker to Azure.

Sample prerequisites

The samples are written in C# and target .NET 7. They require the .NET 7.0 SDK or later.

Building the sample

To download and run the sample, follow these steps:

  1. Download and unzip the sample.
  2. In Visual Studio (2022 or later):
    1. On the menu bar, choose File > Open > Project/Solution.
    2. Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file.
    3. Choose the F5 key to run with debugging, or Ctrl+F5 keys to run the project without debugging.
  3. From the command line:
    1. Navigate to the folder that holds the unzipped sample code.
    2. At the command line, type dotnet run.

More information