Ejemplo n.º 1
0
        private void InitPerformanceCounter(PerformanceCounterInitData data)
        {
            PerformanceCounter pc;

            ExceptionHelper.FalseThrow <ArgumentNullException>(data != null, "data");
            ExceptionHelper.CheckStringIsNullOrEmpty(data.CategoryName, "CategoryName");
            ExceptionHelper.CheckStringIsNullOrEmpty(data.CounterName, "CounterName");

            try
            {
                if (string.IsNullOrEmpty(data.MachineName))
                {
                    pc = new PerformanceCounter(data.CategoryName, data.CounterName, data.InstanceName, data.Readonly);
                }
                else
                {
                    pc = new PerformanceCounter(data.CategoryName, data.CounterName, data.InstanceName, data.MachineName);
                }

                this.counter = pc;
            }
            catch (System.Exception)
            {
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <param name="data">性能计数器的初始化参数</param>
 public PerformanceCounterWrapper(PerformanceCounterInitData data)
 {
     InitPerformanceCounter(data);
 }