- Web Service or Windows Service?
- Installing
- Scheduling
- Performance Counting
- Logging
- Debugging
- Summary
Performance Counting
One of the features of robust Windows services is performance counting. Many log various performance counters so that developers and administrators can easily monitor the performance and behavior of the service using the Performance utility in the Administrative Tools group. As you might expect, the .NET Framework contains several classes in the System.Diagnostics namespace that allow .NET developers to integrate their application with the performance-monitoring system of the operating system.
Using a performance counter in a Windows service is a two-step process. First, the installer class must contain an instance of the PerformanceCounterInstaller class in its Installers collection. The PerformanceCounterInstaller object specifies the name, description, and type of counter that will be installed.
After installation, the service class can reference the performance counter using an instance of the PerformanceCounter class. This object can be used, for example, to increment the counter when a noteworthy event occurs in the service class.