/// <summary> /// 获取cpu信息 /// </summary> /// <returns></returns> public static CPUInformation GetCPUInformation() { try { CPUInformation memInfor = new CPUInformation(); GetSystemInfo(ref memInfor); return(memInfor); } catch (Exception) { return(new CPUInformation()); } }
public static void StopServer() { CPUInformation info = CPUHelper.GetAverage(); if (info != null) { Logger.LogInfo($"Average CPU Usage over {info.secondsPassed}s. %{info.averageOverTime}"); } if (Server == null) { return; } if (!Server.HasExited) { Server.Kill(); } Server = null; }
private static extern void GetSystemInfo(ref CPUInformation cpuinfo);