PerformanceCounterCategory Конструкторы
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Инициализирует новый экземпляр класса PerformanceCounterCategory.
Перегрузки
| Имя | Описание |
|---|---|
| PerformanceCounterCategory() |
Инициализирует новый экземпляр PerformanceCounterCategory класса, оставляет CategoryName свойство пустым и задает MachineName свойство локальному компьютеру. |
| PerformanceCounterCategory(String) |
Инициализирует новый экземпляр PerformanceCounterCategory класса, задает CategoryName свойство указанному значению и задает MachineName свойство локальному компьютеру. |
| PerformanceCounterCategory(String, String) |
Инициализирует новый экземпляр PerformanceCounterCategory класса и задает CategoryNameMachineName свойства указанным значениям. |
PerformanceCounterCategory()
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
Инициализирует новый экземпляр PerformanceCounterCategory класса, оставляет CategoryName свойство пустым и задает MachineName свойство локальному компьютеру.
public:
PerformanceCounterCategory();
public PerformanceCounterCategory();
Public Sub New ()
Примеры
В следующем примере кода принимается PerformanceCounterCategory имя и имя компьютера из командной строки. Он создает PerformanceCounterCategory перегрузку конструктора, соответствующую количеству предоставленных параметров, а затем отображает его свойства.
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 экземпляра с объектом производительности на сервере. В противном случае создается исключение.
См. также раздел
Применяется к
PerformanceCounterCategory(String)
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
Инициализирует новый экземпляр PerformanceCounterCategory класса, задает CategoryName свойство указанному значению и задает MachineName свойство локальному компьютеру.
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 экземпляр.
Исключения
Это categoryName пустая строка ("").
Значение параметра categoryName — null.
Примеры
В следующем примере кода принимается PerformanceCounterCategory имя и имя компьютера из командной строки. Он создает PerformanceCounterCategory перегрузку конструктора, соответствующую количеству предоставленных параметров, а затем отображает его свойства.
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.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
- Исходный код:
- PerformanceCounterCategory.cs
Инициализирует новый экземпляр PerformanceCounterCategory класса и задает CategoryNameMachineName свойства указанным значениям.
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 экземпляр.
- machineName
- String
Компьютер, на котором существуют категория счетчиков производительности и связанные с ним счетчики.
Исключения
Значение параметра categoryName — null.
Примеры
В следующем примере кода принимается PerformanceCounterCategory имя и имя компьютера из командной строки. Он создает PerformanceCounterCategory перегрузку конструктора, соответствующую количеству предоставленных параметров, а затем отображает его свойства.
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