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
)

Parameters

counterId
Type: System.Int32

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

counterType
Type: System.Diagnostics.PerformanceData.CounterType

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

counterName
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
ArgumentException

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

InvalidOperationException

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
Show: