本文整理匯總了C#中System.Diagnostics.PerformanceCounterCategory.PerformanceCounterCategory構造函數的典型用法代碼示例。如果您正苦於以下問題:C# PerformanceCounterCategory構造函數的具體用法?C# PerformanceCounterCategory怎麽用?C# PerformanceCounterCategory使用的例子?那麽, 這裏精選的構造函數代碼示例或許可以為您提供幫助。您也可以進一步了解該構造函數所在類System.Diagnostics.PerformanceCounterCategory
的用法示例。
在下文中一共展示了PerformanceCounterCategory構造函數的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Main
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);
}
}