Windows service runs on the system background without a graphical user interface. You can manually start the service as the system starts automatically or after the system starts. Since it is always running in the background, it gives a sense of behind-the-scenes hero and obscurity. But sometimes the service is very useful.
For example, if our company is engaged in system integration, after the device debugging is complete, the data collected by the device needs to be transmitted to another company's data processing platform in real time, requiring real-time data transmission. It is best to think about making a Windows service. As long as the system starts, the service runs automatically without manual intervention.
Architecture:
1. ServiceProgram
To meet the business needs of the system.
2. service control procedures
Control the start, stop, pause, and continue of a service.
3. service configuration program
The configuration program can install services, register services with the Registry, and set the Service Startup type, service users, and dependencies.
After clarifying the architecture of Windows service, it is very easy to create a service.
Service creation steps:
1. Add project-Windows Service (eg: service1)-Development of service programs to.
2. Right-click the service1 designer and choose add installer to configure
3. Install the service
In step 1, design and develop the [Service Program] in the corresponding architecture, and implement the functions required by the system.
The installer added in step 2 is the service control program and service configuration program in the object architecture]
In step 3, install installutil.exe, the next Installation tool of the. NET Framework, to install the service: installutil.exe service name; uninstall the service: installutil/u service name
In step 1, the development of the service program involves debugging issues. In my opinion, the simple and practical method is to addCodeCopy to service. CS.
Step 2: You can configure service-related attributes and control information on the visual interface, and write code for simple service control, which improves development efficiency.
When I first started writing services, I didn't quite understand it. It was not easy to do. After I finished writing, I felt I had understood a lot. I wanted to make a summary and couldn't write much, so I had to continue learning.
A cool man wrote an article with an example: C # developing a Windows Service Program