The first intimate contact with the Windows service

  
Every time you turn on your computer, Windows XP starts more than 80 services, and the average user knows little about these services running in the background. What exactly do they do? Do I really need all of these services? This tutorial will show you which services are required to run and which services do not have to be running. Start our first intimate contact with the Windows service it.

In many applications, the Windows service needs to be done to operate the database and other operations, such as

(1) some very slow database operations do not want to do a one-time, I want to do it slowly through the regular services, such as regular database backup

(2) using the Windows service to do in .NetRemoting in use vs Host

we can build its .Net Windows service within a few minutes, very simple

said the following about the steps
project
1. Create a new project from a

2. available among the list of templates select Windows service

3. Designer will open in design mode

4. drag a Timer object components from the toolbox onto the table among the design surface (Note: 5. Timer is set to ensure that the component from the list of properties instead of using Windows Forms Timer from among the list)

, Interval attributes 200 milliseconds (1 second database operation 5 times)

6. After filling function for the service

7. Double-click the Timer, and write operations inside the code database, such

SqlConnectionconn = newSqlConnection ( "server = 127.0.0.1; database = test ; uid = sa; pwd = 275280 ");

SqlCommandcomm = -newSqlCommand (" insertintotb1 ( '111', 11) ", conn);

conn.Open ();

comm.ExecuteNonQuery ();

conn.Close ();

8. the handover procedure to the service design view

9. Right-click design view select "Add Setup"

10. ProjectInstaller added just switched to design view

11. property component disposed serviceInstaller1:

1) ServiceName = MySampleService < BR>
2) StartType = automatic (autostart)

12. serviceProcessInstaller1 component attribute set Account = LocalSystem

13. change to your project folder location where binDebug (If you take Release Compile mode in binRelease folder)

14. Run "InstallUtilMyWindowsService.exe" to register this service, it is appropriate to establish a registry entry. (InstallUtil this program in the Windows folder Microsoft.NetFrameworkv1.1.4322 below)

15. Right-click on the desktop "My Computer", select "Management" can play the Computer Management console

16. in the "services and applications" inside the "services" section, you can find your Windows services have been included in the list of services among the

17. Right-click on the service you choose you can start start Service.

key problem is that in fact we can not do without these services, WindowsXP many features are achieved through these services. Simply put, you can think of these services as programs that perform system tasks in the background, such as getting automatic updates or managing print jobs. The biggest difference from the average application is that they all run in the "background", so you basically don't feel they exist.
Copyright © Windows knowledge All Rights Reserved