PerformanceCounterCategory Constructors
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse.
Overloads
| Name | Description |
|---|---|
| PerformanceCounterCategory() |
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse, laat de CategoryName eigenschap leeg en stelt de MachineName eigenschap in op de lokale computer. |
| PerformanceCounterCategory(String) |
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse, stelt de CategoryName eigenschap in op de opgegeven waarde en stelt de MachineName eigenschap in op de lokale computer. |
| PerformanceCounterCategory(String, String) |
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse en stelt de CategoryName en MachineName eigenschappen in op de opgegeven waarden. |
PerformanceCounterCategory()
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse, laat de CategoryName eigenschap leeg en stelt de MachineName eigenschap in op de lokale computer.
public:
PerformanceCounterCategory();
public PerformanceCounterCategory();
Public Sub New ()
Voorbeelden
In het volgende codevoorbeeld worden een PerformanceCounterCategory naam en een computernaam vanaf de opdrachtregel geaccepteerd. Er wordt een PerformanceCounterCategory gebruik gemaakt van de overbelasting van de constructor die geschikt is voor het aantal opgegeven parameters, waarna de eigenschappen worden weergegeven.
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
Opmerkingen
De CategoryName eigenschap moet worden ingesteld voordat u dit PerformanceCounterCategory exemplaar aan een prestatieobject op de server kunt koppelen. Anders wordt er een uitzondering gegenereerd.
Zie ook
Van toepassing op
PerformanceCounterCategory(String)
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse, stelt de CategoryName eigenschap in op de opgegeven waarde en stelt de MachineName eigenschap in op de lokale computer.
public:
PerformanceCounterCategory(System::String ^ categoryName);
public PerformanceCounterCategory(string categoryName);
new System.Diagnostics.PerformanceCounterCategory : string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String)
Parameters
- categoryName
- String
De naam van de prestatiemeteritemcategorie of het prestatieobject waarmee dit PerformanceCounterCategory exemplaar moet worden gekoppeld.
Uitzonderingen
Het categoryName is een lege tekenreeks ("").
De categoryName is null.
Voorbeelden
In het volgende codevoorbeeld worden een PerformanceCounterCategory naam en een computernaam vanaf de opdrachtregel geaccepteerd. Er wordt een PerformanceCounterCategory gebruik gemaakt van de overbelasting van de constructor die geschikt is voor het aantal opgegeven parameters, waarna de eigenschappen worden weergegeven.
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
Zie ook
Van toepassing op
PerformanceCounterCategory(String, String)
Initialiseert een nieuw exemplaar van de PerformanceCounterCategory klasse en stelt de CategoryName en MachineName eigenschappen in op de opgegeven waarden.
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)
Parameters
- categoryName
- String
De naam van de prestatiemeteritemcategorie of het prestatieobject waarmee dit PerformanceCounterCategory exemplaar moet worden gekoppeld.
- machineName
- String
De computer waarop de prestatiemeteritemcategorie en de bijbehorende tellers bestaan.
Uitzonderingen
Het categoryName is een lege tekenreeks ("").
– of –
De machineName syntaxis is ongeldig.
De categoryName is null.
Voorbeelden
In het volgende codevoorbeeld worden een PerformanceCounterCategory naam en een computernaam vanaf de opdrachtregel geaccepteerd. Er wordt een PerformanceCounterCategory gebruik gemaakt van de overbelasting van de constructor die geschikt is voor het aantal opgegeven parameters, waarna de eigenschappen worden weergegeven.
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