How To Write Your Service

Table of contents:

How To Write Your Service
How To Write Your Service

Video: How To Write Your Service

Video: How To Write Your Service

The standard tool for creating a Windows service is the Visual Studio. Net template called Windows Service.

How to write your service
How to write your service

It is necessary

The main benefit of this Windows Service tool is that it automatically creates references to the correct classes and name categories using inheritance and modifying the required methods


Step 1

Make sure that you understand the sequence of steps for creating your service: - correctly defining the service name of the service; - creating the necessary installers; - performing an override; - defining the OnStop and OnStart code; - defining the configuration method for the created service.

Step 2

Use the Properties dialog box to set the desired name for the service you are creating. Note that the selected service name must match the name used by the class installer application. Any change to the value of the name used implies an update of the class installer application.

Step 3

Use the necessary parameters to define the properties and methods of functioning of the created service: - True - in the CanStop section - to allow receiving requests that interrupt execution; - True - in the CanShutDown section - to allow receiving notifications when the computer is turned off that call the OnShutDown procedure; - False - in the CanPauseAndContinue section - to prohibit the interruption and resumption of the service, or True - to allow these actions; - False - in the CanHandlePowerEvents section - to prohibit the service from receiving notifications about changes in the computer's power state, or True - to allow receiving such notifications; - False - in the section AutoLog - to prohibit recording a report of actions performed by the service in the event log, or True - to enable event logging.

Step 4

Call the code editor tool and enter the required processing values for the OnStop and OnStart procedures. Modify the parameters of the values of the methods to be changed in functionality and add the necessary installers for the service being created.

Step 5

Expand the Build menu and enter the Build Solution command without trying to use the F5 function key to start the service. Install the created service.

Popular by topic