/// ------------------------------------------------------------------------------------ /// <summary> /// Returns the physical memory in bytes. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static ulong GetPhysicalMemoryBytes() { #if !__MonoCS__ EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); ManagementObjectHelper helper = new ManagementObjectHelper(waitHandle); ThreadPool.QueueUserWorkItem(helper.GetPhysicalMemoryBytes); waitHandle.WaitOne(); return(helper.Memory); #else using (var pc = new PerformanceCounter("Mono Memory", "Total Physical Memory")) { return((ulong)pc.RawValue); } #endif }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns the physical memory in bytes. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static ulong GetPhysicalMemoryBytes() { #if !__MonoCS__ EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); ManagementObjectHelper helper = new ManagementObjectHelper(waitHandle); ThreadPool.QueueUserWorkItem(helper.GetPhysicalMemoryBytes); waitHandle.WaitOne(); return helper.Memory; #else using (var pc = new PerformanceCounter("Mono Memory", "Total Physical Memory")) { return (ulong)pc.RawValue; } #endif }
/// <summary> /// </summary> /// <param name="t"></param> /// <param name="action"></param> /// <typeparam name="T"></typeparam> public static void ParallelInvoker <T>(this IEnumerable <T> t, Action <T> action) { var cpuCount = ManagementObjectHelper.GetNumberOfCores(); ParallelInvoker(t, cpuCount, action); }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns the disk drive statistics. /// </summary> /// <param name="size"></param> /// <param name="free"></param> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static int GetDiskDriveStats(out ulong size, out ulong free) { EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); ManagementObjectHelper helper = new ManagementObjectHelper(waitHandle); ThreadPool.QueueUserWorkItem(new WaitCallback(helper.GetAvailableDiskMemory)); waitHandle.WaitOne(); size = helper.DiskSize; free = helper.DiskFree; return helper.DriveCount; }
/// ------------------------------------------------------------------------------------ /// <summary> /// Returns the physical memory in bytes. /// </summary> /// <returns></returns> /// ------------------------------------------------------------------------------------ public static ulong GetPhysicalMemoryBytes() { EventWaitHandle waitHandle = new EventWaitHandle(false, EventResetMode.AutoReset); ManagementObjectHelper helper = new ManagementObjectHelper(waitHandle); ThreadPool.QueueUserWorkItem(new WaitCallback(helper.GetPhysicalMemoryBytes)); waitHandle.WaitOne(); return helper.Memory; }