With vs.net, we can establish its Windows service in a few minutes, which is very simple.
The following are the steps
1. Create a project
2. Select Windows Services
3. Slave Toolkit Components Drag a timer object in the table to the design surface, using the system. Timer. Time
4. Set the timer attribute. The interval attribute is 200 milliseconds (5 database operations are performed in 1 second)
5. Double-click the timer and write some database operations in it. Code For example
Sqlconnection conn = new sqlconnection ("Server = Wagner. 0.0.1; database = test; uid = sa; Pwd = 275280 ");
Sqlcommand comm =-New sqlcommand ("insert into tb1 values ('000000', 11)", Conn );
Conn. open ();
Comm. executenonquery ();
Conn. Close ();
6. Set this service Program Switch to design view
7. Right-click the design view and select "add installer"
8. Switch to the design view of the newly added project installer.
9. Set the attributes of the serviceinstaller1 component:
1) servicename = My Sample Service
2) starttype = Automatic startup)
10. Set the serviceprocessinstaller1 component's attribute account = LocalSystem
11. Change the path to the bin \ debug folder of your project (if you compile in release mode, in the bin \ release folder)
12. Execute the command "installutil.exe mywindowsservice.exe" to register this service so that it can create a suitable registration item. (Installutil is in the Windows Folder \ Microsoft. NET \ framework \ v1.1.4322)
13. Right-click "my computer" on the desktop and select "manage" to access the computer management console.
14. In the "services" section of "services and applications", you can find that your Windows services are included in the Service list.
15. Right-click your service and choose start to start your service.