PerformanceCounterCategory.MachineName 속성

정의

이 범주가 있는 컴퓨터의 이름을 가져오거나 설정합니다.

public:
 property System::String ^ MachineName { System::String ^ get(); void set(System::String ^ value); };
public string MachineName { get; set; }
member this.MachineName : string with get, set
Public Property MachineName As String

속성 값

성능 카운터 범주 및 관련 카운터가 있는 컴퓨터의 이름입니다.

예외

MachineName 구문이 잘못된 경우

예제

다음 코드 예제에서는 생성자를 사용 하는 PerformanceCounterCategory 합니다 PerformanceCounterCategory() . 사용자에게 PerformanceCounterCategory 및 컴퓨터 이름을 묻는 메시지를 표시한 다음 입력한 값에서 및 MachineName 속성을 설정합니다CategoryName. 그런 다음 , MachineNameCategoryHelp 속성의 CategoryName값을 표시하거나 에 액세스할 수 없는 경우 PerformanceCounterCategory 오류 메시지를 표시합니다.

public static void Main(string[] args)
{
    string categoryName = "";
    string machineName = "";
    PerformanceCounterCategory pcc = 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)
        {
            pcc.CategoryName = categoryName;
        }
    }
    while (machineName.Length==0)
    {
        Console.Write("Enter a non-blank computer name ['.' for local]: ");
        machineName = Console.ReadLine().Trim();
        if (machineName.Length>0)
        {
            pcc.MachineName = machineName;
        }
    }

    // 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(Exception ex)
    {
        Console.WriteLine("Error getting the properties of the " +
            "PerformanceCounterCategory object:");
        Console.WriteLine(ex.Message);
    }
}
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

적용 대상

추가 정보