|
| 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 5 worker service applications that contain sample source code for interacting with IHostedService, and BackgroundService." |
| 10 | +--- |
| 11 | + |
| 12 | +# Logging 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 related docs content 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 targets .NET 5. It requires the [.NET 5.0 SDK](https://dotnet.microsoft.com/download/dotnet/5.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 (2019 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 | +- [Implement the `IHostedService` interface][timer-svc] |
| 40 | +- [Deploy a Worker Service to Azure][cloud-svc] |
| 41 | + |
| 42 | +[workers]: https://docs.microsoft.com/dotnet/core/extensions/workers |
| 43 | +[queue]: https://docs.microsoft.com/dotnet/core/extensions/queue-service |
| 44 | +[scoped-bgs]: https://docs.microsoft.com/dotnet/core/extensions/scoped-service |
| 45 | +[win-bgs]: https://docs.microsoft.com/dotnet/core/extensions/windows-service |
| 46 | +[timer-svc]: https://docs.microsoft.com/dotnet/core/extensions/timer-service |
| 47 | +[cloud-svc]: https://docs.microsoft.com/dotnet/core/extensions/cloud-service |
0 commit comments