Link to home
Start Free TrialLog in
Avatar of McExp
McExpFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Process.Start Get CPU Time

I'm using a C# .net program (using MONO on RHEL) to invoke the a external process, I'm looking to monitor the process by checking the CPUtime at a defined interval, if the CPU time has not increased I assume the process is dead, kill it off and move on to the next stage. However when I get the CPU time (after a Process.Refresh) it is always 0 are the CPU times not populated on mono or am I missing something?
Avatar of kaufmed
kaufmed
Flag of United States of America image

I have not messed with Mono much as of yet, but the typical way of starting a process and waiting for it to finish in .NET would be:
Process p = new Process();
ProcessStartInfo info = new ProcessStartInfo("/bin/file_to_execute", "list of arguments");

p.StartInfo = info;
p.Start();
p.WaitForExit();

Open in new window

Avatar of McExp

ASKER

Please read my question again, I already have the code working to load the process and monitor the CPU time for the process, However whenever I call the code I get a return of 0 ms. Your example doesn't even propose a solution to do check of CPU time. Please only respond if you can actually help!
Looking at the mono source, Refresh doesn't look like it does anything for the TotalProcessorTime

The TotalProcessorTime method calls a Times method in an assembly specific for your operating system, I've not been able to track down the source for this yet and unfortunately have run out of time. If you've got no answer by tomorrow I'll try and track it down further. Sounds like you may need to raise this with the mono team though.
Good luck.
ASKER CERTIFIED SOLUTION
Avatar of McExp
McExp
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial