CounterSet.AddCounter Method (Int32, CounterType, String)


Adds a counter to the counter set by using the specified counter identifier and type and a display name for the counter.

Namespace:   System.Diagnostics.PerformanceData
Assembly:  System.Core (in System.Core.dll)

public void AddCounter(
	int counterId,
	CounterType counterType,
	string counterName


Type: System.Int32

Identifies the counter. Use the same value that you used in the manifest to define the counter.

Type: System.Diagnostics.PerformanceData.CounterType

Identifies the counter type. The counter type determines how the counter data is calculated, averaged, and displayed.

Type: System.String

Name of the counter. You can use this name to index the counter in the counter set instance. (See CounterSetInstanceCounterDataSet.Item.)

Exception Condition

The counter identifier already exists in the set or is negative, or the counter type is NULL or not valid.


You cannot add counters to the counter set after creating an instance of the counter set.

You must add counters to the counter set before creating an instance of the counter set.

.NET Framework
Available since 3.5
Return to top