PerformanceCounterCategory.MachineName 属性

获取或设置此类别所在的计算机的名称。

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

语法

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

value = instance.MachineName

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

/** @property */
public void set_MachineName (String value)
public function get MachineName () : String

public function set MachineName (value : String)

属性值

性能计数器类别及其关联计数器所在的计算机的名称。

异常

异常类型 条件

ArgumentException

MachineName 语法无效。

示例

下面的代码示例使用 PerformanceCounterCategory 构造函数创建 PerformanceCounterCategory。该示例提示用户输入 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 命名空间
PerformanceCounterCategory.CategoryName 属性
PerformanceCounter 类