本文整理汇总了C#中System.Diagnostics.CounterCreationDataCollection.Clear方法的典型用法代码示例。如果您正苦于以下问题:C# CounterCreationDataCollection.Clear方法的具体用法?C# CounterCreationDataCollection.Clear怎么用?C# CounterCreationDataCollection.Clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Diagnostics.CounterCreationDataCollection
的用法示例。
在下文中一共展示了CounterCreationDataCollection.Clear方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Add
private void Add()
{
this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Adding Performance Counter Category: {0}", this.CategoryName));
CounterCreationDataCollection colCounterCreationData = new CounterCreationDataCollection();
colCounterCreationData.Clear();
if (PerformanceCounterCategory.Exists(this.CategoryName))
{
this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Removing Performance Counter Category: {0}", this.CategoryName));
PerformanceCounterCategory.Delete(this.CategoryName);
}
foreach (ITaskItem counter in this.CounterList)
{
string counterName = counter.GetMetadata("CounterName");
string counterHelp = counter.GetMetadata("CounterHelp");
PerformanceCounterType counterType = (PerformanceCounterType)Enum.Parse(typeof(PerformanceCounterType), counter.GetMetadata("CounterType"));
this.LogTaskMessage(MessageImportance.Low, string.Format(CultureInfo.CurrentCulture, "Adding Performance Counter: {0}", counterName));
CounterCreationData objCreateCounter = new CounterCreationData(counterName, counterHelp, counterType);
colCounterCreationData.Add(objCreateCounter);
}
if (colCounterCreationData.Count > 0)
{
PerformanceCounterCategoryType categoryType = PerformanceCounterCategoryType.SingleInstance;
if (this.MultiInstance)
{
categoryType = PerformanceCounterCategoryType.MultiInstance;
}
this.LogTaskMessage(string.Format(CultureInfo.CurrentCulture, "Creating Performance Counter Category: {0}", this.CategoryName));
PerformanceCounterCategory.Create(this.CategoryName, this.CategoryHelp, categoryType, colCounterCreationData);
}
}