PerformanceCounterCategory Constructeurs
Définition
Important
Certaines informations portent sur la préversion du produit qui est susceptible d’être en grande partie modifiée avant sa publication. Microsoft exclut toute garantie, expresse ou implicite, concernant les informations fournies ici.
Initialise une nouvelle instance de la classe PerformanceCounterCategory.
Surcharges
| Nom | Description |
|---|---|
| PerformanceCounterCategory() |
Initialise une nouvelle instance de la PerformanceCounterCategory classe, laisse la CategoryName propriété vide et définit la MachineName propriété sur l’ordinateur local. |
| PerformanceCounterCategory(String) |
Initialise une nouvelle instance de la PerformanceCounterCategory classe, définit la propriété sur la CategoryName valeur spécifiée et définit la MachineName propriété sur l’ordinateur local. |
| PerformanceCounterCategory(String, String) |
Initialise une nouvelle instance de la PerformanceCounterCategory classe et définit les propriétés et MachineName les CategoryName valeurs spécifiées. |
PerformanceCounterCategory()
Initialise une nouvelle instance de la PerformanceCounterCategory classe, laisse la CategoryName propriété vide et définit la MachineName propriété sur l’ordinateur local.
public:
PerformanceCounterCategory();
public PerformanceCounterCategory();
Public Sub New ()
Exemples
L’exemple de code suivant accepte un PerformanceCounterCategory nom et un nom d’ordinateur à partir de la ligne de commande. Il crée une PerformanceCounterCategory surcharge de constructeur appropriée pour le nombre de paramètres fournis, puis affiche ses propriétés.
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
Remarques
La CategoryName propriété doit être définie avant d’associer cette PerformanceCounterCategory instance à un objet de performance sur le serveur. Sinon, une exception est levée.
Voir aussi
S’applique à
PerformanceCounterCategory(String)
Initialise une nouvelle instance de la PerformanceCounterCategory classe, définit la propriété sur la CategoryName valeur spécifiée et définit la MachineName propriété sur l’ordinateur local.
public:
PerformanceCounterCategory(System::String ^ categoryName);
public PerformanceCounterCategory(string categoryName);
new System.Diagnostics.PerformanceCounterCategory : string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String)
Paramètres
- categoryName
- String
Nom de la catégorie de compteur de performances ou de l’objet de performance auquel associer cette PerformanceCounterCategory instance.
Exceptions
Il categoryName s’agit d’une chaîne vide (« »).
categoryName a la valeur null.
Exemples
L’exemple de code suivant accepte un PerformanceCounterCategory nom et un nom d’ordinateur à partir de la ligne de commande. Il crée une PerformanceCounterCategory surcharge de constructeur appropriée pour le nombre de paramètres fournis, puis affiche ses propriétés.
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
Voir aussi
S’applique à
PerformanceCounterCategory(String, String)
Initialise une nouvelle instance de la PerformanceCounterCategory classe et définit les propriétés et MachineName les CategoryName valeurs spécifiées.
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)
Paramètres
- categoryName
- String
Nom de la catégorie de compteur de performances ou de l’objet de performance auquel associer cette PerformanceCounterCategory instance.
- machineName
- String
Ordinateur sur lequel la catégorie de compteurs de performances et ses compteurs associés existent.
Exceptions
Il categoryName s’agit d’une chaîne vide (« »).
- ou -
La machineName syntaxe n’est pas valide.
categoryName a la valeur null.
Exemples
L’exemple de code suivant accepte un PerformanceCounterCategory nom et un nom d’ordinateur à partir de la ligne de commande. Il crée une PerformanceCounterCategory surcharge de constructeur appropriée pour le nombre de paramètres fournis, puis affiche ses propriétés.
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