RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Creating Windows Services in .NET

When you need to run unattended applications that can monitor directories and log events, don't even think about writing a desktop application—write a Windows service instead.

uppose that your company's field reps regularly upload files to the server, and the proper people need to be notified when these files arrive. Perhaps you need to monitor and log the creation of new folders, to ensure that certain files remain read-only, or to gather use data for reports. These and many other similar tasks are certainly within the capabilities of a standard Windows desktop application, and this is the approach that many developers and system administrators take, either running the application continuously or at regular intervals with the help of the Windows Scheduler. While common, this approach is a pretty sure invitation to headache-city. Being desktop apps, such programs are susceptible to intentional or unintentional fiddling from users. In addition, they require some account to be logged on in order to run.

Fortunately there's a much better alternative for applications that run for extended periods and do not require user interaction: a Windows service. While Windows service applications (previously called NT Services) have been around for a while, they were a real bear to program. With .NET, this has changed. The .NET Framework provides classes that greatly simplify the tasks of creating, installing, and controlling Windows service applications.

While Windows service applications (previously called NT Services) have been around for a while, they were a real bear to program.
A Windows service is a highly specialized type of application designed to run for extended periods in its own Windows session, usually with no user interface. Tasks for which you might use a Windows service include network connection management, disk access monitoring, and certain security tasks. Windows itself always has a variety of services running, most of which the user is never directly aware of. In Windows 2000 you can view a list of services by opening Administrative Tools from the Control Panel, and then opening Computer Management and selecting Services on the navigation tree. The ability to create and deploy Windows services is not something that developers need to do on a regular basis, but in some situations it is by far the best solution.

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date