Share via


PerformanceCounterCategory Constructores

Definición

Inicializa una nueva instancia de la clase PerformanceCounterCategory.

Sobrecargas

PerformanceCounterCategory()

Inicializa una nueva instancia de la clase PerformanceCounterCategory, deja la propiedad CategoryName vacía y establece la propiedad MachineName en el equipo local.

PerformanceCounterCategory(String)

Inicializa una nueva instancia de la clase PerformanceCounterCategory, establece la propiedad CategoryName en el valor especificado y establece la propiedad MachineName en el equipo local.

PerformanceCounterCategory(String, String)

Inicializa una nueva instancia de la clase PerformanceCounterCategory y establece las propiedades CategoryName y MachineName en los valores especificados.

PerformanceCounterCategory()

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

Inicializa una nueva instancia de la clase PerformanceCounterCategory, deja la propiedad CategoryName vacía y establece la propiedad MachineName en el equipo local.

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

Ejemplos

En el ejemplo de código siguiente se acepta un PerformanceCounterCategory nombre y un nombre de equipo de la línea de comandos. Crea un PerformanceCounterCategory mediante la sobrecarga del constructor adecuada para el número de parámetros proporcionados y, a continuación, muestra sus propiedades.

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

Comentarios

La CategoryName propiedad debe establecerse antes de asociar esta PerformanceCounterCategory instancia con un objeto de rendimiento en el servidor. De lo contrario, se inicia una excepción.

Consulte también

Se aplica a

PerformanceCounterCategory(String)

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

Inicializa una nueva instancia de la clase PerformanceCounterCategory, establece la propiedad CategoryName en el valor especificado y establece la propiedad MachineName en el equipo local.

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

Parámetros

categoryName
String

Nombre de la categoría de contador de rendimiento u objeto de rendimiento al que se va a asociar esta instancia de PerformanceCounterCategory.

Excepciones

categoryName es una cadena vacía ("").

El valor de categoryName es null.

Ejemplos

En el ejemplo de código siguiente se acepta un PerformanceCounterCategory nombre y un nombre de equipo de la línea de comandos. Crea un PerformanceCounterCategory mediante la sobrecarga del constructor que es adecuada para el número de parámetros proporcionados y, a continuación, muestra sus propiedades.

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

Consulte también

Se aplica a

PerformanceCounterCategory(String, String)

Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs
Source:
PerformanceCounterCategory.cs

Inicializa una nueva instancia de la clase PerformanceCounterCategory y establece las propiedades CategoryName y MachineName en los valores especificados.

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)

Parámetros

categoryName
String

Nombre de la categoría de contador de rendimiento u objeto de rendimiento al que se va a asociar esta instancia de PerformanceCounterCategory.

machineName
String

Equipo en el que residen la categoría del contador de rendimiento y los contadores asociados.

Excepciones

categoryName es una cadena vacía ("").

o bien

La sintaxis de machineName no es válida.

El valor de categoryName es null.

Ejemplos

En el ejemplo de código siguiente se acepta un PerformanceCounterCategory nombre y un nombre de equipo de la línea de comandos. Crea un PerformanceCounterCategory mediante la sobrecarga del constructor que es adecuada para el número de parámetros proporcionados y, a continuación, muestra sus propiedades.

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

Consulte también

Se aplica a