internal dynamic GetProcessMemoryInfo(string processName)
        {
            var memory = new PerformanceCounterCategory(".NET CLR Memory", ".").GetCounters(processName);

            return(new
            {
                TotalMiB = memory.FirstOrDefault(i => i.CounterName == "# Bytes in all Heaps").NextValue() / 1024 / 1024,
                LOHSizeMiB = memory.FirstOrDefault(i => i.CounterName == "Large Object Heap size").NextValue() / 1024 / 1024,
            });
        }
        public PerformanceMonitor()
        {
            // Initialize counters.
            _cpuCounter    = new PerformanceCounter("Processor", "% Processor Time", "_Total", true);
            _memoryCounter = new PerformanceCounter("Memory", "Available KBytes", true);

            string drive = DriveManager.GetSystemDrive();

            string[] instanceNameArray = new PerformanceCounterCategory("PhysicalDisk").GetInstanceNames();
            string   instanceName      = instanceNameArray.FirstOrDefault(s => s.IndexOf(drive) > -1);

            _diskIOCounter = new PerformanceCounter("PhysicalDisk", "% Idle Time", instanceName, true);

            // Initialize timer.
            Timer = new Timer(1000);
        }