Microsoft Windows Services/NT services, allow us to create long-running applications that run in the background repetitively without the need of any user interface or user interaction like Windows Forms Application, WPF Application, Console Application.
There are different ways to create
Windows Services applications using the .NET Framework, but the one way is to use open source project Topshelf.
Topshelf is an open source Windows service framework for the .NET platform that makes it easy to create a Windows service.
Why would I use Topshelf to create Windows service?
It makes it easy to create a Windows service as well as test the service, debug the service, and install it into the Windows Service Control Manager (SCM) with simple commands.
By using Topshelf, we don’t need to understand the complex details of service classes, perform installation via InstallUtil, or learn how to attach the debugger to services for troubleshooting issues.
With Topshelf, creating a Windows service is as easy as creating a console application. Once the console application is created, we need to create a single service class with public Start and Stop methods and configure asa service using Topshelf’s configuration API.
Now, we have a complete Windows service that can be debugged using the debugger (just by pressing F5) and installed using the Topshelf command (install/uninstall).
Here is link to Topshelf open source project
documentation.
Following are the steps to create Windows service in .Net with Topshelf: