Pages

Tuesday, November 15, 2016

Microsoft Windows services, formerly known as NT services, enable you to create long-running executable applications that run in their own Windows sessions. These services can be automatically started when the computer boots, can be paused and restarted, and do not show any user interface.

ABService is part of the AvioBrain project. This is the first library with an open-source license from AvioBrain.

In order to build a Windows Service Application on .NET and Visual Studio you have to create a Windows Service project.
Then you have to implement the main ServiceBase class overriding at least the OnStart and OnStop methods.
The OnStart is the method triggered when the service starts up, OnStop is triggered when the service is been request to stop.
You can also add a class that implements the service Installer. This will gives you the opportunity to simplify the install process of your service.

This library extends the ServiceBase and Installer class and lets the user just write the worker part of the service.

It offers a console mode, that can be started using the --run arguments.
The install process it's been triggered by the --install command, this will install the service on your machine.
The --uninstall command will auto-remove the service.

The ABService core, runs a timer every second, although the timer interval can be changed in code.
The main timer will check if the service worker function is running, if not, it will start the user worker method.

The sample project will show how to use this library in your service.
In a few step, the user will:

Build up the custom worker method, it could be as simple as a void Do() method inside a class.

Edit the Program.cs main file. This will start the ABService runner

Edit the main windows service item, extending the ABService one. Here is where we set up the main check timer, and the worker method.

Edit the service installer class, extendint the ABService one. This will implements all the install/uninstall features.