Beispiel #1
0
 public ProcessInfo(ProcessMemento memento)
     : this()
 {
     Name = memento.Name;
     Pid = memento.Pid;
     Update(memento);
 }
        private void CollectInformationTask()
        {
            int currentId = Process.GetCurrentProcess().Id;
            while (true)
            {
                Process[] currentProcesses = Process.GetProcesses();
                // Сбор информации о процессах
                List<ProcessMemento> currentMementos = new List<ProcessMemento>();
                lock (Watcher.Processes)
                {
                    foreach (Process process in currentProcesses)
                    {
                        ProcessMemento memento = new ProcessMemento();
                        memento.Name = process.ProcessName;
                        try
                        {
                            using (PerformanceCounter pcProcess = new PerformanceCounter("Process", "% Processor Time", process.ProcessName))
                            {
                                memento.CpuUsing = new CpuUsingInfo(pcProcess.RawValue);
                            }
                        }
                        catch
                        {
                            memento.CpuUsing = new CpuUsingInfo(0);
                        }
                        memento.MemoryUsing = new MemoryUsingInfo(process.WorkingSet64);
                        memento.ThreadsCount = new ThreadCount(process.Threads.Count);
                        memento.Pid = process.Id;

                        currentMementos.Add(memento);
                    }
                    AddInfo(currentMementos);
                }
                // mass centers
                ComputeMassCenters(currentProcesses);
                Thread.Sleep(CollectInformationInterval);
            }
        }
Beispiel #3
0
 public void Update(ProcessMemento info)
 {
     AddCpuUsingInfo(info.CpuUsing);
     AddMemoryUsingInfo(info.MemoryUsing);
     AddThreadsCountInfo(info.ThreadsCount);
 }