An open API service indexing awesome lists of open source software.

https://github.com/amirdoosti6060/backgroundservicedemo

A small sample that shows how to create and register background service in .Net
https://github.com/amirdoosti6060/backgroundservicedemo

asynchronous-programming background-service csharp dotnet

Last synced: about 1 month ago
JSON representation

A small sample that shows how to create and register background service in .Net

Awesome Lists containing this project

README

          

# BackgroundServiceDemo

## Introduction
This project provide a sample that shows how to implement a **Background Service** in .Net 6.
I also wrote an article in the following address that completely explains **Background Services**:
https://www.linkedin.com/pulse/background-services-cnet-amir-doosti-e3vcf

## Structure of soution
The solution contains one Console App project which is written in Visual Studio. The project contains a **Worker** class which runs in the background and generate strings with random numbers. It raise an event almost every 1 second and deliver the message. In Program.cs, our Worker class is registered and also subscribed to receive event and write it down to the console. Please note how I used **Singleton Registeration** technique.

## Technology stack
- OS: Windows 10 Enterprise - 64 bits
- IDE: Visual Studio Enterprise 2022 (64 bits) - version 17.2.5
- Framework: .Net 6
- Language: C#

## How to run
Open the solution in Visual Studio and run it using F5. You will see the output in a console.
Press Ctrl+C to exit the program.