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
- Host: GitHub
- URL: https://github.com/amirdoosti6060/backgroundservicedemo
- Owner: amirdoosti6060
- Created: 2024-01-14T06:36:55.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-01-14T07:08:53.000Z (over 2 years ago)
- Last Synced: 2025-03-17T09:11:42.177Z (over 1 year ago)
- Topics: asynchronous-programming, background-service, csharp, dotnet
- Language: C#
- Homepage: https://www.linkedin.com/pulse/background-services-cnet-amir-doosti-e3vcf
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
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.