private void readCounterValue() { Config conf = new Config(); var countersConfig = conf.GetCounters(); if (countersConfig.Count == 0) { EventLog.WriteEntry(eventSource, "В файле конфигурации не определены счетчики."); this.Stop(); } DataWriter writer = new DataWriter(conf.FileIntervalWrite(), conf.SendIntervalData()); List <PerformanceCounter> perfCounters = new List <PerformanceCounter>(); foreach (Config.Counter counterInfo in countersConfig) { perfCounters.Add(new PerformanceCounter(counterInfo.Category, counterInfo.CounterName, counterInfo.Instance)); } while (_keepGoing) { foreach (PerformanceCounter perfCounter in perfCounters) { double counterValue = perfCounter.NextValue(); writer.AppendData(perfCounter, counterValue); } Thread.Sleep(1000 * conf.CounterIntervalRead()); } }