Beispiel #1
0
        public void TrackTotal(Process p, EntityViewModel viewModel)
        {
            PerformanceCounter cpuCounter = new PerformanceCounter
            {
                CategoryName = "PhysicalDisk",
                CounterName  = "% Disk Time",
                InstanceName = "_Total"
            };
            Thread t = new Thread(() =>
            {
                while (!interrupted && !p.HasExited)
                {
                    try
                    {
                        viewModel.DiskValueUpdate(cpuCounter.NextValue());
                    } catch (Exception e) { break; }
                    Thread.Sleep(500);
                }
                viewModel.DiskValueUpdate(0.0);
                viewModel.DiskValueUpdate(0.0);
                viewModel.DiskValueUpdate(0.0);
            });

            t.Start();
            threads.Add(t);
        }