コード例 #1
0
ファイル: Program.cs プロジェクト: jaapjolman/getpidinfo
 void ProcessInfoThread()
 {
     processInfoManager = new ProcessInfoManager(numberOfProcessInfoSamplesToAverage, secondsToKeepWatchingProcessWithNoRequests);
     while (Thread.CurrentThread.ThreadState == ThreadState.Running)
     {
         Thread.Sleep(updateProcessInfoEveryMiliseconds);
         processInfoManager.Tick();
     }
 }
コード例 #2
0
 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));
     }
 }
コード例 #3
0
        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();
        }