using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text;
namespace Azylee.Core.AppUtils
{
public class AppInfoTool
{
///
/// 读取APP占用CPU
///
///
public static double CPU()
{
double value = 0;
Process p = null;
PerformanceCounter processor = null;
try
{
p = Process.GetCurrentProcess();
processor = new PerformanceCounter("Process", "% Processor Time", p.ProcessName);
value = processor.NextValue();
}
catch { }
finally
{
processor?.Dispose();
p?.Dispose();
}
return value;
}
///
/// 读取APP占用内存
///
///
public static long RAM()
{
long value = 0;
Process p = null;
try
{
p = Process.GetCurrentProcess();
value = p.WorkingSet64;
}
catch { }
finally { p?.Dispose(); }
return value;
}
}
}