Hello,
I am trying to write an application that gets the amount of CPU that a process is using , its throwing an a Win 32 exception that says Access is denied to the UserProcessorTi me property ....enclosed is the code , any way that i can resolve this and access the property ?
I am trying to write an application that gets the amount of CPU that a process is using , its throwing an a Win 32 exception that says Access is denied to the UserProcessorTi me property ....enclosed is the code , any way that i can resolve this and access the property ?
Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
execute();
}
public static void execute()
{
Process[] currentProcess = Process.GetProcesses();
string[] processes = new string[currentProcess.Length];
int k = 0;
while (k < currentProcess.Length)
{
processes[k] = currentProcess[k].Id + " " + currentProcess[k].ProcessName + " " + currentProcess[k].WorkingSet64 + " " + currentProcess[k].Threads.Count + " " + currentProcess[k].UserProcessorTime;
++k;
}
System.Console.ReadLine();
}
}
}
Comment