Hi,
is there any way that I can count the computer inactivity time using a C# program??? If yes can you give some example code??
Thanks,
Anthony
Hi,
is there any way that I can count the computer inactivity time using a C# program??? If yes can you give some example code??
Thanks,
Anthony
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
AlanPosted Sep 3, 2007, 7:12 PM
In .NET 1.1, you could get CPU utilization time for the System Idle Process, which has a process id of 0, using the System.Diagnostics.Process.GetProcessById(0).TotalProcessorTime property.
However, if you try this in .NET 2.0, then for some unknown reason you'll get an 'access denied' exception :(
It's still possible to get this information via the PerformanceCounter class and I'd check out this Code Project article for a discussion of the matter:
http://www.codeproject.com/csharp/processescpuusage.asp