不添加或删除性能计数器?

时间:2012-03-12 08:23:17

标签: .net windows iis-7 performancecounter

您好,

我在IIS7中托管了一个WCF服务,该服务在启动时运行以下代码:

    if ((_UsePerformanceCounters = bool.Parse(ConfigurationManager.AppSettings["UsePerformanceCounters"])))
    {
        col = new CounterCreationDataCollection();
        counter = new CounterCreationData(_acountOfCurrentUsersCounterName, "Amount of current users", PerformanceCounterType.NumberOfItemsHEX32);
        col.Add(counter);

        if (PerformanceCounterCategory.Exists(_categoryName))
            PerformanceCounterCategory.Delete(_categoryName);

        if (!PerformanceCounterCategory.Exists(_categoryName))
            category = PerformanceCounterCategory.Create(_categoryName, "MyApp Application Service Counters", PerformanceCounterCategoryType.MultiInstance, col);
        else
            Console.WriteLine("Counter already exists");

        if (PerformanceCounterCategory.CounterExists(_acountOfCurrentUsersCounterName, _categoryName))
            _amountOfCurrentUsers = new PerformanceCounter(_categoryName, _acountOfCurrentUsersCounterName, HostingEnvironment.MapPath("~"), false);
    }

我可以看到每次删除并添加类别但我仍然无法在性能监视器中看到它?

它确实出现了一次,但即使在删除和Exists = false时,计数器也会像以前一样重新出现?周末过后它消失了?

表演监察员不可思议吗?我应该使用其他一些软件吗?或者我做错了什么?

1 个答案:

答案 0 :(得分:0)

这是一个刷新问题,我需要重启性能监视器以清除缓存。