
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Implementing a Simple Performance Counter
|
465
The read-only SubKeyCount property and GetSubKeyNames method of the RegistryKey
class are used to obtain the number of subkeys that reside under a particular key and
a string array containing their names.
The
FindSourceNamesFromLog method uses the GetSubKeyNames method to obtain a list
of event logs from the
EventLog registry key. It then searches these log names until the
log name passed to this method through the
logName parameter is found. Once the cor-
rect log is found, its subkeys—representing all of the sources tied to that log—are
saved to the
sourceNamesList array. This array is then passed back to the caller.
See Also
See Recipe 8.7; see the “Registry.LocalMachine Field” and “RegistryKey.Open
Method” topics in the MSDN documentation.
8.11 Implementing a Simple Performance Counter
Problem
You need to use a performance counter to track application-specific information.
The simpler performance counters find, for example, the change in a counter value
between successive samplings or just count the number of times an action occurs.
Other, more complex counters exist but are not dealt with in this recipe. For exam-
ple, a custom counter could be built to keep track of the number of database transac-
tions, the number of failed network connections ...