当前位置: 首页>>代码示例>>C#>>正文


C# CounterCreationDataCollection.Clear方法代码示例

本文整理汇总了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);
            }
        }
开发者ID:hamidshahid,项目名称:MSBuildExtensionPack,代码行数:34,代码来源:PerformanceCounters.cs


注:本文中的System.Diagnostics.CounterCreationDataCollection.Clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。