Presentation is loading. Please wait.

Presentation is loading. Please wait.

Windows Service Applications

Similar presentations


Presentation on theme: "Windows Service Applications"— Presentation transcript:

1 Windows Service Applications
A Windows Service application consists of two parts: The application executable. The services derived from the ServiceBase class. In the application executable, you implement the Main method to control the applications services. To create any Windows Service application, you must have a class derived from the ServiceBase class. The ServiceBase class implements virtual methods for functionality required by the Service Control Manager (SCM).

2 Windows Service Applications
A Windows Service application has the following characteristics: Does not have a UI. It is designed to run for a very long time. The execution of the Windows Service application is separate from the services execution and functionality.

3 Windows Service Applications
You start and stop the Windows Service application executable independently of starting and stopping the service. A Windows Service application can run without a user being logged on to the machine. Typically, a Windows Service application runs under the System Account, but a specific account can be provided.

4 Windows Service Applications
Although the executable may always be running, the service can be stopped, started, paused, or continued. The SCM uses the ServiceBase class’s OnStop, OnStart, OnPause, OnContinue, and OnShutdown (of the machine) methods to control the service’s behavior. The service can also set property values like CanStop, CanPauseAndContinue, and CanShutdown to inform the SCM which methods are supported.

5 Windows Service Applications
Once a Windows Service application is installed, the Service Control Manager (SCM) executes the application and the Main method is run. The Main method performs any application initialization code and then creates the services within the executable.

6 Computer Management Console with SCM Selected

7 Debugging Windows Services Applications
Debugging is a process of finding the cause of errors in a program, locating the lines of code that are causing those errors, and fixing those errors. Visual Studio provides a number of tools that provide a streamlined approach to debugging all kind of applications such as Windows Forms, Windows Services ,and Console Applications.

8 Common Debugging Mechanisms
Breakpoint Quick Watch Window Watch Window Output Window Immediate Window Locals Window Call Stack Window Threads Window Memory Window

9 Debugging a Window Service Application
A Windows Service application is always executing with one or more services running internally. To debug, you must first attach to the Windows Services application: then you will have the standard Visual Studio debugging tools available. The Attach Process is the procedure used by Visual Studio to monitor an already running executable and allow debugging.

10 Attach to Process Editor

11 Summary You learned how to create a Windows Form event, some of the common Windows Form events, and how to handle a Raised event. You learned how to create a WPF event, the differences among bubbled, tunneled, and direct WPF events, and how to handle a Raised event throughout the control hierarchy. You learned about the Windows Services application, the ServiceBase class, and how to override the ServiceBase class default methods. You learned how to debug Windows Services applications using the Attach Process Editor and the common debugging windows.


Download ppt "Windows Service Applications"

Similar presentations


Ads by Google