This project is read-only.
To add performance counters to your applications will be easier than ever. Now you can give your programs the final improvements that you want without a headache.

how to add to your running application:
  • Add a reference to the assembly PerformanceCounterHelper.dll in your project.
  • Then make a enum within your application that will hold all the performance counters you want. Then use the "PerformanceCounterCategoryAttribute" into the enum type to add needed properties such as category name, category description and category type (single instance or multiple instance)
  • Then within the enum elements add a "PerformanceCounterAttribute" attribute to describe the counter name, counter description, and Counter Type

Here I leave you a enum as an example (you can find a complete example in the source-code section).

    	"Detail information about the test application.")]
    public enum SingleInstance_PerformanceCounters
        	"Example Quantity", 

        	"Example Average Counter", 

  • After saving and compiling your application use the intaller given in this solution called "PerformanceCounterHelper.Installer.exe" with the name of the assembly that contains the enum above to install the counters into the system that will run your application (This is done this way because it is possible than the application will run with less privileges than Administrator; and you need to be Administrator to install counters into the system)
  • After that you can start using the performance counters within your applicacion code as follow:

    using (CounterHelper<SingleInstance_PerformanceCounters>  counterHelper = 

    using (CounterHelper<SingleInstance_PerformanceCounters>  counterHelper = 
        counterHelper.IncrementBy(PerformanceCounters.AverageCountExample, value);

And then you are done. Start your application and start Perfmon and you will see your counters and will start to play around with them as in the following example:


Last edited Nov 30, 2009 at 4:32 PM by javiercanillas, version 2


No comments yet.