Reputation: 225
I have the following question:
In UWP, how can we get an overall CPU percentage usage, RAM usage,free RAM, Running process, etc? It's required for task manager in UWP.
Upvotes: 3
Views: 1806
Reputation: 701
You can access the total system memory and CPU usage with the SystemDiagnosticInfo class.
var diagnosticInfo = SystemDiagnosticInfo.GetForCurrentSystem();
// Total physical RAM
ulong totalMemory = diagnosticInfo.MemoryUsage.GetReport().TotalPhysicalSizeInBytes;
var cpuUsage = diagnosticInfo.CpuUsage.GetReport();
// Total kernel/user/idle time since system start
var kernelTime = cpuUsage.KernelTime
var userTime = cpuUsage.UserTime
var idleTime = cpuUsage.IdleTime
To get CPU usage as a percentage, you need to take measurements at two different points in time (e.g. 100ms apart), then calculate (deltaKernelTime + deltaUserTime) / (deltaKernelTime + deltaUserTime + deltaIdleTime).
Upvotes: 0
Reputation:
Hi after doing some looking it doesn't seem as if you can get the device CPU, RAM and Free Ram or the Running Processes. You can get the CPU, memory as well as the memory limits for an application.
You can get these through the following ways:
RAM: This is accessed through the MemoryManager Class
MemoryManager.AppMemoryUsage
And there are some other static members that will help you.
CPU: As for CPU this is retrieved using - Windows.System.Diagnostics.ProcessCpuUsage
Upvotes: 7