The tasks carried out by Windows Services are typically long-running tasks and have little or no direct interaction with a user. Many of the constituent parts of Windows and other products use Windows Services to carry out their functions. For example, some versions of Windows install an indexing service to enable searching of the file system. IIS and SQL Server both use Windows Services for important functionality. Such applications may be started when the computer is booted and often continue to run until the computer is shut down.
Example scenarios for creating your own Windows Services would include programs such as the following:
- A file watcher—Suppose you are running an FTP server that enables users to place files in a particular directory. You could use a Windows Service to monitor and process files within that directory as they arrive. The service runs in the background and detects when files are changed or added within the directory, and then extracts information from these files in order to process orders, or update address and billing information. You will see an example of such a Windows Service later in this chapter.
- An automated stock price reporter—You could build a system that extracts stock prices from a Web service or website and then e-mails the information to users. You could set thresholds such that an e-mail is sent only when the stock price reaches a certain price. This Windows Service can be automated to extract the information every 10 ...