CounterSet.AddCounter 方法

定義

將計數器加入至計數器集合。

多載

AddCounter(Int32, CounterType)

使用指定的計數器識別項和型別,將計數器加入至計數器集合。

AddCounter(Int32, CounterType, String)

使用指定的計數器識別項和型別以及計數器的顯示名稱,將計數器加入至計數器集合。

AddCounter(Int32, CounterType)

來源:
CounterSet.cs
來源:
CounterSet.cs
來源:
CounterSet.cs

使用指定的計數器識別項和型別,將計數器加入至計數器集合。

public:
 void AddCounter(int counterId, System::Diagnostics::PerformanceData::CounterType counterType);
public void AddCounter (int counterId, System.Diagnostics.PerformanceData.CounterType counterType);
member this.AddCounter : int * System.Diagnostics.PerformanceData.CounterType -> unit
Public Sub AddCounter (counterId As Integer, counterType As CounterType)

參數

counterId
Int32

識別計數器。 請使用您在資訊清單中使用的同一個值來定義計數器。

counterType
CounterType

識別計數器型別。 此計數器型別決定計數器資料的計算、求平均值及顯示等方式。

例外狀況

計數器識別項已存在集合中或為負數,或者計數器型別是 NULL 或無效。

您不能在建立計數器集合的執行個體之後,將計數器加入至計數器集合。

備註

您必須在建立計數器集合的執行個體前,將計數器加入至計數器集合中。

適用於

AddCounter(Int32, CounterType, String)

來源:
CounterSet.cs
來源:
CounterSet.cs
來源:
CounterSet.cs

使用指定的計數器識別項和型別以及計數器的顯示名稱,將計數器加入至計數器集合。

public:
 void AddCounter(int counterId, System::Diagnostics::PerformanceData::CounterType counterType, System::String ^ counterName);
public void AddCounter (int counterId, System.Diagnostics.PerformanceData.CounterType counterType, string counterName);
member this.AddCounter : int * System.Diagnostics.PerformanceData.CounterType * string -> unit
Public Sub AddCounter (counterId As Integer, counterType As CounterType, counterName As String)

參數

counterId
Int32

識別計數器。 請使用您在資訊清單中使用的同一個值來定義計數器。

counterType
CounterType

識別計數器型別。 此計數器型別決定計數器資料的計算、求平均值及顯示等方式。

counterName
String

計數器的名稱。 您可以使用這個名稱,對計數器集合'執行個體中的計數器進行索引 (請參閱Item[String].)

例外狀況

計數器識別項已存在集合中或為負數,或者計數器型別是 NULL 或無效。

您不能在建立計數器集合的執行個體之後,將計數器加入至計數器集合。

範例

如需範例,請參閱 System.Diagnostics.PerformanceData

備註

您必須在建立計數器集合的執行個體前,將計數器加入至計數器集合中。

適用於