I need to calculate total '% Processor Time', without using any performance counter.?????
NOTE:
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.
Abhishek JainPosted Aug 29, 2013, 10:42 AM
Please try this:
var managementObjectSearcher = new ManagementObjectSearcher(@"\\
ManagementObjectCollection managementObjectCollection = managementObjectSearcher.Get();
ManagementObject managementObject = managementObjectCollection.Cast
int totalTime = managementObject["PercentProcessorTime"];
For this code to work you need to add reference of System.Management.dll to your project.
Regards
AJ