PerformanceCounterCategory Конструкторы
Определение
Инициализирует новый экземпляр класса PerformanceCounterCategory.Initializes a new instance of the PerformanceCounterCategory class.
Перегрузки
PerformanceCounterCategory() |
Инициализирует новый экземпляр класса PerformanceCounterCategory, оставляет пустым свойство CategoryName и задает в качестве значения свойства MachineName локальный компьютер.Initializes a new instance of the PerformanceCounterCategory class, leaves the CategoryName property empty, and sets the MachineName property to the local computer. |
PerformanceCounterCategory(String) |
Инициализирует новый экземпляр класса PerformanceCounterCategory, задает для свойства CategoryName указанное значение, а в качестве значения свойства MachineName устанавливает локальный компьютер.Initializes a new instance of the PerformanceCounterCategory class, sets the CategoryName property to the specified value, and sets the MachineName property to the local computer. |
PerformanceCounterCategory(String, String) |
Инициализирует новый экземпляр класса PerformanceCounterCategory и присваивает свойствам CategoryName и MachineName указанные значения.Initializes a new instance of the PerformanceCounterCategory class and sets the CategoryName and MachineName properties to the specified values. |
PerformanceCounterCategory()
Инициализирует новый экземпляр класса PerformanceCounterCategory, оставляет пустым свойство CategoryName и задает в качестве значения свойства MachineName локальный компьютер.Initializes a new instance of the PerformanceCounterCategory class, leaves the CategoryName property empty, and sets the MachineName property to the local computer.
public:
PerformanceCounterCategory();
public PerformanceCounterCategory ();
Public Sub New ()
Примеры
В следующем примере кода в PerformanceCounterCategory командной строке принимается имя и имя компьютера.The following code example accepts a PerformanceCounterCategory name and a computer name from the command line. Он создает PerformanceCounterCategory с помощью перегрузки конструктора, соответствующей указанному количеству параметров, а затем отображает его свойства.It creates a PerformanceCounterCategory using the constructor overload appropriate for the number of parameters provided, then displays its properties.
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
Комментарии
CategoryNameСвойство должно быть установлено перед связыванием этого PerformanceCounterCategory экземпляра с объектом производительности на сервере.The CategoryName property must be set before associating this PerformanceCounterCategory instance with a performance object on the server. В противном случае создается исключение.Otherwise, an exception is thrown.
См. также раздел
Применяется к
PerformanceCounterCategory(String)
Инициализирует новый экземпляр класса PerformanceCounterCategory, задает для свойства CategoryName указанное значение, а в качестве значения свойства MachineName устанавливает локальный компьютер.Initializes a new instance of the PerformanceCounterCategory class, sets the CategoryName property to the specified value, and sets the MachineName property to the local computer.
public:
PerformanceCounterCategory(System::String ^ categoryName);
public PerformanceCounterCategory (string categoryName);
new System.Diagnostics.PerformanceCounterCategory : string -> System.Diagnostics.PerformanceCounterCategory
Public Sub New (categoryName As String)
Параметры
- categoryName
- String
Имя категории счетчиков производительности (объекта производительности), с которым связывается данный экземпляр PerformanceCounterCategory.The name of the performance counter category, or performance object, with which to associate this PerformanceCounterCategory instance.
Исключения
Значением параметра categoryName
является пустая строка ("").The categoryName
is an empty string ("").
Значение параметра categoryName
— null
.The categoryName
is null
.
Примеры
В следующем примере кода в PerformanceCounterCategory командной строке принимается имя и имя компьютера.The following code example accepts a PerformanceCounterCategory name and a computer name from the command line. Он создает PerformanceCounterCategory с помощью перегрузки конструктора, которая подходит для указанного числа параметров, а затем отображает его свойства.It creates a PerformanceCounterCategory using the constructor overload that is appropriate for the number of parameters provided, then displays its properties.
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
См. также раздел
Применяется к
PerformanceCounterCategory(String, String)
Инициализирует новый экземпляр класса PerformanceCounterCategory и присваивает свойствам CategoryName и MachineName указанные значения.Initializes a new instance of the PerformanceCounterCategory class and sets the CategoryName and MachineName properties to the specified values.
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)
Параметры
- categoryName
- String
Имя категории счетчиков производительности (объекта производительности), с которым связывается данный экземпляр PerformanceCounterCategory.The name of the performance counter category, or performance object, with which to associate this PerformanceCounterCategory instance.
- machineName
- String
Компьютер, на котором находятся счетчик производительности и связанная с ним категория.The computer on which the performance counter category and its associated counters exist.
Исключения
Значением параметра categoryName
является пустая строка ("").The categoryName
is an empty string ("").
-или--or-
Неправильный синтаксис параметра machineName
.The machineName
syntax is invalid.
Значение параметра categoryName
— null
.The categoryName
is null
.
Примеры
В следующем примере кода в PerformanceCounterCategory командной строке принимается имя и имя компьютера.The following code example accepts a PerformanceCounterCategory name and a computer name from the command line. Он создает PerformanceCounterCategory с помощью перегрузки конструктора, которая подходит для указанного числа параметров, а затем отображает его свойства.It creates a PerformanceCounterCategory using the constructor overload that is appropriate for the number of parameters provided, then displays its properties.
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