void ProcessInfoThread() { processInfoManager = new ProcessInfoManager(numberOfProcessInfoSamplesToAverage, secondsToKeepWatchingProcessWithNoRequests); while (Thread.CurrentThread.ThreadState == ThreadState.Running) { Thread.Sleep(updateProcessInfoEveryMiliseconds); processInfoManager.Tick(); } }
public PidInfoData QueryProcess(int pid) { if (!ProcessInfoManager.IsRunning(pid)) { // PID not running return(new PidInfoData()); } else { var cpuMemory = processInfoManager.GetCpuMemoryUsageForPid(pid); var network = portStatisticsManager.GetBytesSentLastSecondForPid(pid); return(new PidInfoData(cpuMemory, network)); } }
public PidConnector() { portStatisticsManager = new PortStatisticsManager(secondsToKeepNetworkSamples, secondsToClosePIDPortsWithNoRequests, secondsToUpdatePidToPortsTable); portStatisticsManagerThread = new Thread(PortStatisticsManagerThread) { Name = "portStatisticsManagerThread", IsBackground = true, CurrentCulture = System.Globalization.CultureInfo.InvariantCulture }; portStatisticsManagerThread.Start(); processInfoManager = new ProcessInfoManager(numberOfProcessInfoSamplesToAverage, secondsToKeepWatchingProcessWithNoRequests); processInfoThread = new Thread(ProcessInfoThread) { Name = "processInfoThread", IsBackground = true, CurrentCulture = System.Globalization.CultureInfo.InvariantCulture }; processInfoThread.Start(); }