This is a function being used by a thread that checks Memory Usage. It is in a testing format(A lot of Console.WriteLines :/), but I have a small problem. Whenever I try to write "percMemRemaining" to the Console it outputs 0. Any thoughts or solutions to this problem? P.S As you can tell, I'm very new to this. Thank You.
static void CheckMemUsage()
{
var computerInfo = new ComputerInfo();
var Memory = computerInfo.TotalPhysicalMemory;
Memory = Memory / (1024*1024);
PerformanceCounter memRemaining = PerformanceCounter("Memory", "Available MBytes");
while (true)
{
int MemRemaining = (int)memRemaining.NextValue();
Console.WriteLine("Total Physical Memory: {0} MB",(int)Memory);
Console.WriteLine("Total Remaining Memory: {0} MB", MemRemaining);
ulong _MemRemaining = (ulong)MemRemaining;
ulong percMemRemaining = ((_MemRemaining / Memory) * 100);
Console.WriteLine("Percentage of Memory Used: {0} %", (int)percMemRemaining);
Thread.Sleep(1000);
}
}