| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Linq;
- using System.Text;
- namespace Azylee.Core.AppUtils
- {
- public class AppInfoTool
- {
- /// <summary>
- /// 读取APP Processor(可读取App的CPU使用率)
- /// </summary>
- /// <returns></returns>
- public static PerformanceCounter Processor()
- {
- Process p = null;
- PerformanceCounter processor = null;
- try
- {
- p = Process.GetCurrentProcess();
- processor = new PerformanceCounter("Process", "% Processor Time", p.ProcessName);
- }
- catch { }
- return processor;
- }
- /// <summary>
- /// 读取APP占用内存(单位:KB)
- /// </summary>
- /// <returns></returns>
- public static long RAM()
- {
- long value = 0;
- Process p = null;
- try
- {
- p = Process.GetCurrentProcess();
- value = p.WorkingSet64 / 1024;
- }
- catch { }
- finally { p?.Dispose(); }
- return value;
- }
- }
- }
|