NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Creating Performance Counter Categories

You can create a new category to contain custom counters. For example, if you plan to create a series of counters to track various data about the orders processed on your Web site, you might create a category called OrderData on your server and then create the counters you need within it.

Creating a category is not a distinct process from creating the counters that are placed within it; counters can only be created at the point when you create the category itself. There are several ways you can create counters and categories:

To create a category and a single counter within it

  1. Call the CreateCategory method and specify the following parameters.
    Parameter Value
    CategoryName Any category name that is not already in use on this server.
    CategoryHelp A description of the category.
    CounterName A name for the counter.
    CounterHelp A description of the counter. This text is displayed in Windows Performance Monitor when a user selects a counter and clicks the Explain button.

The following example shows how you might create a simple category with the CreateCategory method:

[Visual Basic]
Sub CreateCustomCounter()
      PerformanceCounter.CreateCategory "MyCategory", "Desc", "MyCounter", "Counterdesc"
End Sub
[C#]
void CreateCustomCounter() {
      PerformanceCounter.CreateCategory ("MyCategory", "Desc", "MyCounter", "Counterdesc");
}

See Also

Creating Custom Performance Counters  | Category and Counter Management