Skip to content

2024.7

Latest
Compare
Choose a tag to compare
@ldqk ldqk released this 12 Dec 01:38
· 3 commits to master since this release
  1. 增加获取指定进程的CPU和内存用量
var process = Process.GetProcessById(1234);
var cpuUsage = process.GetProcessCpuUsage();
var memory = process.GetProcessMemory();

var processes = Process.GetProcessesByName("msedge");
foreach (var p in processes)
{
    var cpu = p.GetProcessCpuUsage();
    var mem = p.GetProcessMemory();
    Console.WriteLine($"Process {p.ProcessName} CPU: {cpu}%, Memory: {mem}MB");
}
  1. 增加System.Text.Json版本序列化反序列化拓展方法支持 #124
var obj = new
{
    Id = 1,
    name = "van",
    addressInfo = new
    {
        street = "123 Main St",
        city = "zcvz",
    },
    remarks = new List<string> { "Deep  Dark  Fantastic", "爱玩游戏♂" },
};

var json = obj.ToJsonString(new JsonSerializerOptions() { Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping });