Example #1
0
        /// ------------------------------------------------------------------------------------
        /// <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
        }
Example #2
0
 /// ------------------------------------------------------------------------------------
 /// <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
 }
Example #3
0
        /// <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);
        }
Example #4
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}
Example #5
0
		/// ------------------------------------------------------------------------------------
		/// <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;
		}