O'Reilly logo

Programming Windows® Services with Microsoft® Visual Basic® 2008 by Michael Gernaey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required