PerformanceCounterCategory Konstruktory

Definicja

Inicjuje nowe wystąpienie klasy PerformanceCounterCategory.

Przeciążenia

PerformanceCounterCategory()

Inicjuje PerformanceCounterCategory nowe wystąpienie klasy, pozostawia właściwość pustą CategoryName i ustawia MachineName właściwość na komputer lokalny.

PerformanceCounterCategory(String)

Inicjuje PerformanceCounterCategory nowe wystąpienie klasy, ustawia CategoryName właściwość na określoną wartość i ustawia MachineName właściwość na komputer lokalny.

PerformanceCounterCategory(String, String)

Inicjuje PerformanceCounterCategory nowe wystąpienie klasy i ustawia CategoryName właściwości i MachineName na określone wartości.

PerformanceCounterCategory()

Źródło:
PerformanceCounterCategory.cs
Źródło:
PerformanceCounterCategory.cs
Źródło:
PerformanceCounterCategory.cs

Inicjuje PerformanceCounterCategory nowe wystąpienie klasy, pozostawia właściwość pustą CategoryName i ustawia MachineName właściwość na komputer lokalny.

public:
 PerformanceCounterCategory();
public PerformanceCounterCategory ();
Public Sub New ()

Przykłady

Poniższy przykład kodu akceptuje PerformanceCounterCategory nazwę i nazwę komputera z wiersza polecenia. Tworzy PerformanceCounterCategory przy użyciu przeciążenia konstruktora odpowiedniego dla podanej liczby parametrów, a następnie wyświetla jego właściwości.

public static void Main(string[] args)
{
    string categoryName = "";
    string machineName = "";
    PerformanceCounterCategory pcc;

    // Copy the supplied arguments into the local variables.
    try
    {
        categoryName = args[0];
        machineName = args[1]=="."? "": args[1];
    }
    catch(Exception ex)
    {
        // Ignore the exception from non-supplied arguments.
    }

    // Create a PerformanceCounterCategory object using
    // the appropriate constructor.
    if (categoryName.Length==0)
    {
        pcc = new PerformanceCounterCategory();
    }
    else if(machineName.Length==0)
    {
        pcc = new PerformanceCounterCategory(categoryName);
    }
    else
    {
        pcc = new PerformanceCounterCategory(categoryName, 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 PerformanceCounterCategory

    ' Copy the supplied arguments into the local variables.
    Try
        categoryName = args(0)
        machineName = IIf(args(1) = ".", "", args(1))
    Catch ex As Exception
        ' Ignore the exception from non-supplied arguments.
    End Try

    ' Create a PerformanceCounterCategory object using 
    ' the appropriate constructor.
    If categoryName.Length = 0 Then
        pcc = New PerformanceCounterCategory
    ElseIf machineName.Length = 0 Then
        pcc = New PerformanceCounterCategory(categoryName)
    Else
        pcc = New PerformanceCounterCategory(categoryName, machineName)
    End If

    ' 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

Uwagi

Właściwość musi zostać ustawiona CategoryName przed skojarzeniem tego PerformanceCounterCategory wystąpienia z obiektem wydajności na serwerze. W przeciwnym razie jest zgłaszany wyjątek.

Zobacz też

Dotyczy

PerformanceCounterCategory(String)

Źródło:
PerformanceCounterCategory.cs
Źródło:
PerformanceCounterCategory.cs
Źródło:
PerformanceCounterCategory.cs

Inicjuje PerformanceCounterCategory nowe wystąpienie klasy, ustawia CategoryName właściwość na określoną wartość i ustawia MachineName właściwość na komputer lokalny.

public:
 PerformanceCounterCategory(System::String ^ categoryName);
public PerformanceCounterCategory (string categoryName);
new System.Diagnostics.PerformanceCounterCategory : string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String)

Parametry

categoryName
String

Nazwa kategorii licznika wydajności lub obiektu wydajności, z którym ma być skojarzone to PerformanceCounterCategory wystąpienie.

Wyjątki

Jest categoryName to pusty ciąg ("").

Wartość categoryName to null.

Przykłady

Poniższy przykład kodu akceptuje PerformanceCounterCategory nazwę i nazwę komputera z wiersza polecenia. PerformanceCounterCategory Tworzy przy użyciu przeciążenia konstruktora, które jest odpowiednie dla podanej liczby parametrów, a następnie wyświetla jego właściwości.

public static void Main(string[] args)
{
    string categoryName = "";
    string machineName = "";
    PerformanceCounterCategory pcc;

    // Copy the supplied arguments into the local variables.
    try
    {
        categoryName = args[0];
        machineName = args[1]=="."? "": args[1];
    }
    catch(Exception ex)
    {
        // Ignore the exception from non-supplied arguments.
    }

    // Create a PerformanceCounterCategory object using
    // the appropriate constructor.
    if (categoryName.Length==0)
    {
        pcc = new PerformanceCounterCategory();
    }
    else if(machineName.Length==0)
    {
        pcc = new PerformanceCounterCategory(categoryName);
    }
    else
    {
        pcc = new PerformanceCounterCategory(categoryName, 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 PerformanceCounterCategory

    ' Copy the supplied arguments into the local variables.
    Try
        categoryName = args(0)
        machineName = IIf(args(1) = ".", "", args(1))
    Catch ex As Exception
        ' Ignore the exception from non-supplied arguments.
    End Try

    ' Create a PerformanceCounterCategory object using 
    ' the appropriate constructor.
    If categoryName.Length = 0 Then
        pcc = New PerformanceCounterCategory
    ElseIf machineName.Length = 0 Then
        pcc = New PerformanceCounterCategory(categoryName)
    Else
        pcc = New PerformanceCounterCategory(categoryName, machineName)
    End If

    ' 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

Zobacz też

Dotyczy

PerformanceCounterCategory(String, String)

Źródło:
PerformanceCounterCategory.cs
Źródło:
PerformanceCounterCategory.cs
Źródło:
PerformanceCounterCategory.cs

Inicjuje PerformanceCounterCategory nowe wystąpienie klasy i ustawia CategoryName właściwości i MachineName na określone wartości.

public:
 PerformanceCounterCategory(System::String ^ categoryName, System::String ^ machineName);
public PerformanceCounterCategory (string categoryName, string machineName);
new System.Diagnostics.PerformanceCounterCategory : string * string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String, machineName As String)

Parametry

categoryName
String

Nazwa kategorii licznika wydajności lub obiektu wydajności, z którym ma być skojarzone to PerformanceCounterCategory wystąpienie.

machineName
String

Komputer, na którym istnieje kategoria licznika wydajności i skojarzone z nim liczniki.

Wyjątki

Jest categoryName to pusty ciąg ("").

-lub-

Składnia jest nieprawidłowa machineName .

Wartość categoryName to null.

Przykłady

Poniższy przykład kodu akceptuje PerformanceCounterCategory nazwę i nazwę komputera z wiersza polecenia. PerformanceCounterCategory Tworzy przy użyciu przeciążenia konstruktora, które jest odpowiednie dla podanej liczby parametrów, a następnie wyświetla jego właściwości.

public static void Main(string[] args)
{
    string categoryName = "";
    string machineName = "";
    PerformanceCounterCategory pcc;

    // Copy the supplied arguments into the local variables.
    try
    {
        categoryName = args[0];
        machineName = args[1]=="."? "": args[1];
    }
    catch(Exception ex)
    {
        // Ignore the exception from non-supplied arguments.
    }

    // Create a PerformanceCounterCategory object using
    // the appropriate constructor.
    if (categoryName.Length==0)
    {
        pcc = new PerformanceCounterCategory();
    }
    else if(machineName.Length==0)
    {
        pcc = new PerformanceCounterCategory(categoryName);
    }
    else
    {
        pcc = new PerformanceCounterCategory(categoryName, 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 PerformanceCounterCategory

    ' Copy the supplied arguments into the local variables.
    Try
        categoryName = args(0)
        machineName = IIf(args(1) = ".", "", args(1))
    Catch ex As Exception
        ' Ignore the exception from non-supplied arguments.
    End Try

    ' Create a PerformanceCounterCategory object using 
    ' the appropriate constructor.
    If categoryName.Length = 0 Then
        pcc = New PerformanceCounterCategory
    ElseIf machineName.Length = 0 Then
        pcc = New PerformanceCounterCategory(categoryName)
    Else
        pcc = New PerformanceCounterCategory(categoryName, machineName)
    End If

    ' 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

Zobacz też

Dotyczy