This documentation is archived and is not being maintained.

Category and Counter Management 

You create categories and custom performance counters if you want to track data that is not captured by the standard counters provided with Microsoft Windows. For example, you might create a custom counter to track the total number of users logged on to your Web site, or to track the orders processed per second by your site. When you create a counter, you add it to a performance counter category, and you assign it a type that governs how it will behave. For information on choosing the correct type, see Performance Counter Types.

Creating Custom Counters

There are several ways you can create custom counters:

You must create counters in a user-defined category rather than in the performance objects (called categories in Visual Studio and the .NET Framework) defined by Windows. That is, you cannot create a new counter within the Processor category or any other system-defined categories. Additionally, you must create a counter in a new category; adding a counter to an existing user-defined category will raise an exception.

The following restrictions apply to the process of creating new counters:

  • You can create custom counters on the local computer, provided that you have administrator access.

  • If you do not specify a counter type when creating the counter and its category, it will default to NumberofItems32.

  • You cannot create new counters within existing categories. If you need to add counters to categories that already exist, the only way you can do so is to delete the category and recreate it with all of its contents, including the new counters you want to add.

  • There are security restrictions that affect your ability to create counters and categories. For more information, see Introduction to Monitoring Performance Thresholds.

  • The PerformanceCounter class is not fully supported on Microsoft Windows NT version 4.0. You can read from the system counters, but you cannot create, write to, or delete custom counters.

See Also