示例#1
0
        public static PerformanceInformation GetCurrent()
        {
            PerformanceInformation pi = new PerformanceInformation();

            if (GetPerformanceInfo(out pi, Marshal.SizeOf(pi)))
            {
                return(pi);
            }
            else
            {
                throw new InvalidOperationException("GetPerformanceInfo returns false");
            }
        }
示例#2
0
        public static int GetMemoryUsage()
        {
            var pi = PerformanceInformation.GetCurrent();

            return((int)(100 * pi.CommitTotal / pi.PhysicalTotal));
        }
示例#3
0
 public static extern bool GetPerformanceInfo([Out] out PerformanceInformation PerformanceInformation, [In] int Size);