Implementing Our Counters in Code
Although we have created the category and we have created the code to create the counters, we haven’t yet created any code that will implement and use the counters in our code. If we don’t do this, the counters will be useless to anyone who wants to view them. Let’s review how to implement counters and expose their values to the consumers.
Creating Instances of Counters
We need to create an instance of each counter in the service so that we can modify the values of those counters as the service runs. To create instances of the counters, we use the PerformanceCounter class. Before we can create a usable instance of a counter, we have to know the counter name and the instance we wish to read or write to. In the case ...
Get Programming Windows® Services with Microsoft® Visual Basic® 2008 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.