示例#1
0
        /// <summary>
        /// 获取cpu信息
        /// </summary>
        /// <returns></returns>
        public static CPUInformation GetCPUInformation()
        {
            try
            {
                CPUInformation memInfor = new CPUInformation();

                GetSystemInfo(ref memInfor);

                return(memInfor);
            }
            catch (Exception)
            {
                return(new CPUInformation());
            }
        }
示例#2
0
        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;
        }
示例#3
0
 private static extern void GetSystemInfo(ref CPUInformation cpuinfo);