PerformanceCounter.CounterName 属性

获取或设置与此 PerformanceCounter 实例关联的性能计数器的名称。

**命名空间:**System.Diagnostics
**程序集:**System(在 system.dll 中)

语法

声明
Public Property CounterName As String
用法
Dim instance As PerformanceCounter
Dim value As String

value = instance.CounterName

instance.CounterName = value
public string CounterName { get; set; }
public:
property String^ CounterName {
    String^ get ();
    void set (String^ value);
}
/** @property */
public String get_CounterName ()

/** @property */
public void set_CounterName (String value)
public function get CounterName () : String

public function set CounterName (value : String)

属性值

计数器的名称,它一般描述计数的数量。此名称显示在性能计数器管理器 MMC 管理单元的“添加计数器”对话框的计数器列表中。

异常

异常类型 条件

ArgumentNullException

CounterName 为 空引用(在 Visual Basic 中为 Nothing)。

PlatformNotSupportedException

平台为 Windows 98 或 Windows Millennium Edition (Me),这些平台不支持性能计数器。

示例

Dim PC As New PerformanceCounter()
PC.CategoryName = "Process"
PC.CounterName = "Private Bytes"
PC.InstanceName = "Explorer"
MessageBox.Show(PC.NextValue().ToString())
PerformanceCounter PC=new PerformanceCounter();
PC.CategoryName="Process";
PC.CounterName="Private Bytes";
PC.InstanceName="Explorer";
MessageBox.Show(PC.NextValue().ToString());
PerformanceCounter^ PC = gcnew PerformanceCounter;
PC->CategoryName = "Process";
PC->CounterName = "Private Bytes";
PC->InstanceName = "Explorer";
MessageBox::Show( PC->NextValue().ToString() );
PerformanceCounter pc = new PerformanceCounter();
pc.set_CategoryName("Process");
pc.set_CounterName("Private Bytes");
pc.set_InstanceName("Explorer");
MessageBox.Show(((Single)pc.NextValue()).ToString());

平台

Windows 98、Windows 2000 SP4、Windows Server 2003、Windows XP Media Center Edition、Windows XP Professional x64 Edition、Windows XP SP2、Windows XP Starter Edition

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

PerformanceCounter 类
PerformanceCounter 成员
System.Diagnostics 命名空间