public static void TimerLoop() { // https://stackoverflow.com/questions/13019433/calling-a-method-every-x-minutes new System.Threading.Timer((e) => { PerformanceInfo.GetInfo(); System.Console.WriteLine("....................................."); }, null, TimeSpan.Zero, TimeSpan.FromSeconds(1)); }
public static void GetInfo() { Int64 phav = PerformanceInfo.GetPhysicalAvailableMemoryInMiB(); Int64 tot = PerformanceInfo.GetTotalMemoryInMiB(); decimal percentFree = ((decimal)phav / (decimal)tot) * 100; decimal percentOccupied = 100 - percentFree; Console.WriteLine("Available Physical Memory (MiB) " + phav.ToString()); Console.WriteLine("Total Memory (MiB) " + tot.ToString()); Console.WriteLine("Free (%) " + percentFree.ToString()); Console.WriteLine("Occupied (%) " + percentOccupied.ToString()); }