winmr-api/Models/ProcessBaseInfo.cs

86 lines
2.3 KiB
C#
Raw Normal View History

2025-07-02 16:06:50 +03:00
// File: Models/ProcessBaseInfo.cs
using System.Text.Json.Serialization;
namespace WebmrAPI.Models
{
public class ProcessBaseInfo : MemoryRegion
{
2025-07-03 15:22:40 +03:00
public enum ProcessStatus
{
Undefined,
Running,
NotResponding
}
2025-07-02 16:06:50 +03:00
private TimeSpan _lastPTime = TimeSpan.Zero;
private TimeSpan _curPTime = TimeSpan.Zero;
private int _pid = 0;
private int _ppid = -1;
private int _tcount = 0;
private string? _name = null;
private string? _fname = null;
private string? _cmd = null;
private ProcessStatus _status = ProcessStatus.Undefined;
private DateTime? _startTime = null;
private double _cpuUsage = 0;
[JsonIgnore]
public TimeSpan TotalProcessorTime
{
set { lock (_lock) { _lastPTime = _curPTime; _curPTime = value; } }
}
[JsonIgnore]
public double ProcessorTime
{
2025-07-02 18:13:00 +03:00
get { lock (_lock) return (_curPTime - _lastPTime).TotalMilliseconds; }
2025-07-02 16:06:50 +03:00
}
public int PID
{
get => LockedGet(ref _pid);
set => LockedSet(ref _pid, value);
}
public int ParentPID
{
get => LockedGet(ref _ppid);
set => LockedSet(ref _ppid, value);
}
public string? Name
{
get => LockedGet(ref _name);
set => LockedSet(ref _name, value);
}
public string? FileName
{
get => LockedGet(ref _fname);
set => LockedSet(ref _fname, value);
}
public string? CommandLine
{
get => LockedGet(ref _cmd);
set => LockedSet(ref _cmd, value);
}
public int ThreadCount
{
get => LockedGet(ref _tcount);
set => LockedSet(ref _tcount, value);
}
public ProcessStatus Status
{
get => LockedGet(ref _status);
set => LockedSet(ref _status, value);
}
public DateTime? StartTime
{
get => LockedGet(ref _startTime);
set => LockedSet(ref _startTime, value);
}
public double CpuUsage
{
get => LockedGet(ref _cpuUsage);
set => LockedSet(ref _cpuUsage, value);
}
}
}