Esempio n. 1
0
        public PerfCounterRealTimeProbe(IObserver <PerformanceSample> observer, TimeSpan samplingRate, params string[] counterPaths)
            : base(observer)
        {
            PdhStatus status = PdhNativeMethods.PdhOpenQuery(null, IntPtr.Zero, out _query);

            PdhUtils.CheckStatus(status, PdhStatus.PDH_CSTATUS_VALID_DATA);

            for (int i = 0; i < counterPaths.Length; i++)
            {
                AddCounter(counterPaths[i], i);
            }

            _timer = new Timer(OnTimer, null, TimeSpan.Zero, samplingRate);
        }
        public PerfCounterFileReader(IObserver <PerformanceSample> observer, string file)
            : base(observer)
        {
            string extension = Path.GetExtension(file);

            if (extension != null)
            {
                _binaryLog = extension.ToLowerInvariant() == ".blg";
            }

            string[] counterPaths = PdhUtils.GetCounterPaths(file);

            PdhStatus status = PdhNativeMethods.PdhOpenQuery(file, IntPtr.Zero, out _query);

            PdhUtils.CheckStatus(status, PdhStatus.PDH_CSTATUS_VALID_DATA);

            for (int i = 0; i < counterPaths.Length; i++)
            {
                AddCounter(counterPaths[i], i);
            }

            Read();
        }