You often need programs that continuously run in the background. For example, an email server is expected to continuously listen on a network port for incoming email messages, a print spooler is expected to continuously listen for print requests , and so on.
Most operating systems provide a way to create such long-running background tasks . In fact, operating systems themselves run a variety of background processes critical for their functionality. In Unix, the background tasks are called daemons. In Windows NT, the background tasks are called NT services, whereas in the Window 2000, XP, and Windows .NET operating systems, the background tasks are called Windows services.
Although Windows services are created as normal executable files, they have at least two distinct characteristics:
Windows services must conform to the interface of the Service Control Manager (SCM). The SCM is a part of the Windows operating system responsible for managing Windows services.
Windows services must be installed in the Windows service database before they can be used.
In this chapter, you'll use the .NET Framework class libraries to develop the following skills that will help you to create your own Windows services:
Creating a Windows service that conforms to the interface of Windows Service Control Manager (SCM).
Creating an installer class that is capable of installing a Windows service to the Windows service database.
Using the Installer tool (installutil.exe) to install and uninstall a Windows service in the Windows service database.
Connecting to a Windows service and issuing commands such as start, stop, pause, and continue.
Querying a Windows service to retrieve its status.