Reputation: 2513
I'm looking for a simple way to measure the usage of windows devices, I've been looking at uptime as per below, but the issue is that it's from since it was last restarted and i want active use. For example my laptop says 22 hours because i restarted it 22 hours ago, but i wasn't using it overnight as it was in sleep mode.
get
{
using (var uptime = new PerformanceCounter("System", "System Up Time"))
{
uptime.NextValue(); //Call this an extra time before reading its value
return TimeSpan.FromSeconds(uptime.NextValue());
}
}
Upvotes: 0
Views: 96