|
1 | | ---- |
2 | | -languages: |
3 | | -- csharp |
4 | | -products: |
5 | | -- dotnet |
6 | | -page_type: sample |
7 | | -name: "Worker Services in .NET" |
8 | | -urlFragment: "csharp-workers-fundamentals" |
9 | | -description: "Several .NET 6 worker service applications that contain sample source code for interacting with IHostedService, and BackgroundService." |
10 | | ---- |
11 | | - |
12 | | -# Worker Services in .NET sample source code |
13 | | - |
14 | | -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][workers] 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. |
15 | | - |
16 | | -## Sample prerequisites |
17 | | - |
18 | | -The samples are written in C# and target .NET 7. They require the [.NET 7.0 SDK](https://dotnet.microsoft.com/download/dotnet/7.0) or later. |
19 | | - |
20 | | -## Building the sample |
21 | | - |
22 | | -To download and run the sample, follow these steps: |
23 | | - |
24 | | -1. Download and unzip the sample. |
25 | | -2. In Visual Studio (2022 or later): |
26 | | - 1. On the menu bar, choose **File** > **Open** > **Project/Solution**. |
27 | | - 2. Navigate to the folder that holds the unzipped sample code, and open the C# project (.csproj) file. |
28 | | - 3. Choose the <kbd>F5</kbd> key to run with debugging, or <kbd>Ctrl</kbd>+<kbd>F5</kbd> keys to run the project without debugging. |
29 | | -3. From the command line: |
30 | | - 1. Navigate to the folder that holds the unzipped sample code. |
31 | | - 2. At the command line, type [`dotnet run`](https://docs.microsoft.com/dotnet/core/tools/dotnet-run). |
32 | | - |
33 | | -## More information |
34 | | - |
35 | | -- [Worker Services in .NET][workers] |
36 | | -- [Create a Queue Service][queue] |
37 | | -- [Use scoped services within a `BackgroundService`][scoped-bgs] |
38 | | -- [Create a Windows Service using `BackgroundService`][win-bgs] |
39 | | -- [Create a Windows Service installer][win-inst] |
40 | | -- [Implement the `IHostedService` interface][timer-svc] |
41 | | -- [Deploy a Worker Service to Azure][cloud-svc] |
42 | | - |
43 | | -[workers]: https://learn.microsoft.com/dotnet/core/extensions/workers |
44 | | -[queue]: https://learn.microsoft.com/dotnet/core/extensions/queue-service |
45 | | -[scoped-bgs]: https://learn.microsoft.com/dotnet/core/extensions/scoped-service |
46 | | -[win-bgs]: https://learn.microsoft.com/dotnet/core/extensions/windows-service |
47 | | -[win-inst]: https://learn.microsoft.com/dotnet/core/extensions/windows-service-with-installer |
48 | | -[timer-svc]: https://learn.microsoft.com/dotnet/core/extensions/timer-service |
49 | | -[cloud-svc]: https://learn.microsoft.com/dotnet/core/extensions/cloud-service |
0 commit comments