PerformanceCounterCategory.CategoryName 属性

获取或设置定义此类别的性能对象的名称。

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

语法

声明
Public Property CategoryName As String
用法
Dim instance As PerformanceCounterCategory
Dim value As String

value = instance.CategoryName

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

/** @property */
public void set_CategoryName (String value)
public function get CategoryName () : String

public function set CategoryName (value : String)

属性值

性能计数器类别的名称或性能对象,此 PerformanceCounterCategory 实例将与之关联。

异常

异常类型 条件

ArgumentException

CategoryName 是空字符串 ("")。

ArgumentNullException

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

示例

下面的代码示例创建一个包含一个 PerformanceCounterCategoryPerformanceCounterCategory。它提示用户输入 PerformanceCounterCategory 和计算机名称,然后根据输入的值设置 CategoryNameMachineName 属性。接着,该示例显示 CategoryNameMachineNameCategoryHelp 属性的值;或者如果无法访问 PerformanceCounterCategory,它将显示一条错误信息。

Sub Main(ByVal args() As String)
    Dim categoryName As String = ""
    Dim machineName As String = ""
    Dim pcc As New PerformanceCounterCategory

    ' Prompt for fields and set the corresponding properties.
    While categoryName.Length = 0
        Console.Write("Please enter a non-blank category name: ")
        categoryName = Console.ReadLine().Trim
        If categoryName.Length > 0 Then
            pcc.CategoryName = categoryName
        End If
    End While
    While machineName.Length = 0
        Console.Write( _
            "Enter a non-blank computer name ['.' for local]: ")
        machineName = Console.ReadLine().Trim
        If machineName.Length > 0 Then
            pcc.MachineName = machineName
        End If
    End While

    ' Display the properties of the PerformanceCounterCategory object.
    Try
        Console.WriteLine("  Category:  {0}", pcc.CategoryName)
        Console.WriteLine("  Computer:  {0}", pcc.MachineName)
        Console.WriteLine("  Help text: {0}", pcc.CategoryHelp)
    Catch ex As Exception
        Console.WriteLine("Error getting the properties of the " & _
            "PerformanceCounterCategory object:")
        Console.WriteLine(ex.Message)
    End Try
End Sub

.NET Framework 安全性

平台

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

请参见

参考

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