Posts

Showing posts with the label 2019 at 09:20AM

Create windows services in C#

In this blog post, we will go over on how to create windows services in C#. Windows services are started when OS boots and runs the service in the background. It can start automatically or can be made to start, stop or run based on manual trigger. Here is how you can create your own windows service: Open Visual Studio, go to File > New and select Project. Go to Visual C# -> ”Windows Desktop” -> ”Windows Service,” give your project an appropriate name and then click OK. Once you click OK, there will be a black screen with Service1.cs[design] file opened. Now, right click on a blank area, and select Add Installer. We need to add installers to windows service before you run the service, which registers with service control managers. After adding installer, it adds ProjectInstaller.cs to the project. Once you view the code of Project Installer, you would see InitialiseComponent method. Once you go to the definition of it, here you can mention the name of service, descripti...