15.6. Create a Windows Service

Problem

You need to create an application that will run as a Windows service.

Solution

Create a class that extends System.ServiceProcess.ServiceBase. Use the inherited properties to control the behavior of your service, and override inherited methods to implement the functionality required. Implement a Main method that creates an instance of your service class and passes it to the Shared ServiceBase.Run method.

NOTE

The ServiceBase class is defined in the System.ServiceProcess assembly, so you must include a reference to this assembly when you build your service class.

How It Works

To create a Windows service manually, you must implement a class derived from the ServiceBase class. The ServiceBase class provides ...

Get Visual Basic 2008 Recipes: A Problem-Solution Approach now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.