Ejemplo n.º 1
0
        private void FillNewCustomProcess(out CustomProcess customProcess, Process p, bool addInfo)
        {
            var nextValue = 0f;

            lock (Locker)
            {
                nextValue = _performanceCountersReadOnly
                            .ToList().Find(pc => pc.Id == p.Id).Next;
            }
            customProcess = new CustomProcess()
            {
                Name         = p.ProcessName,
                Id           = p.Id,
                IsResponding = p.Responding,
                Cpu          = Math.Round(nextValue, 2),
                Gpu          = Math.Round(p.WorkingSet64 / (10.24 * _ramKb), 2),
                StartTime    = p.StartTime,
                PathToFile   = p.MainModule?.FileName,
                Username     = GetUserName(p)
            };

            foreach (ProcessThread thread in p.Threads)
            {
                customProcess.ThreadsCount++;
                if (!addInfo)
                {
                    continue;
                }
                customProcess.Threads.Add(new CustomProcessThreads()
                {
                    Id        = thread.Id,
                    StartTime = thread.StartTime,
                    State     = thread.ThreadState.ToString()
                });
            }

            if (!addInfo)
            {
                return;
            }

            foreach (ProcessModule module in p.Modules)
            {
                customProcess.Modules.Add(new CustomProcessModule()
                {
                    Name = module.ModuleName,
                    Path = module.FileName
                });
            }
        }
Ejemplo n.º 2
0
 private static dynamic ReturnPropertyValue(CustomProcess process, ProcessProperties property)
 {
     return(property switch
     {
         ProcessProperties.Name => process.Name,
         ProcessProperties.Id => process.Id,
         ProcessProperties.IsResponding => process.IsResponding,
         ProcessProperties.Cpu => process.Cpu,
         ProcessProperties.Gpu => process.Gpu,
         ProcessProperties.Username => process.Username,
         ProcessProperties.StartTime => process.StartTime,
         ProcessProperties.PathToFile => process.PathToFile,
         ProcessProperties.ThreadsCount => process.ThreadsCount,
         _ => process.Name
     });