public void TestMonitorTask()
        {
            var watcher = System.Diagnostics.Stopwatch.StartNew();
            MonitorConfiguration conf = MonitorConfiguration.Load(@"..\..\..\EnhancedMonitoring\Configuration\EnhancedMonitoringProviderConfig.xml");

            conf.LogFilePath = @"C:\ProgramData\Enhanced Monitoring\log\monitor.log";
            conf.LogLevel    = "Verbose";
            Logger.Init(conf);
            MonitoringTask task = MonitoringTask.CreateInstance(conf as MonitorConfiguration);

            task.Run();
            Console.WriteLine(String.Format("Elapsed: {0}ms", watcher.ElapsedMilliseconds));
        }
        private void RunMonitoringTask(MonitorConfiguration conf)
        {
            Logger.Info("Start monitoring task");
            DateTime       start = DateTime.Now;
            MonitoringTask task  = MonitoringTask.CreateInstance(conf);

            task.Run();
            Logger.Info("Monitoring task finished");
            TimeSpan elapsed = DateTime.Now.Subtract(start);
            //Substract elapsed time to get the task running exaclty aliging to refresh rate.
            long interval   = Math.Max(conf.RefreshRate, MIN_REFRESH_RATE) * 1000;
            long timeToWait = interval - (long)elapsed.TotalMilliseconds % interval;

            //Trigger next task
            timer.Change(timeToWait, Timeout.Infinite);
        }