By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,290 Members | 1,263 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,290 IT Pros & Developers. It's quick & easy.

How to use Process ID (PID) to get elapsed CPU time?

P: n/a
HI:

I have a Process ID (PID) and want to continually query how much
elapsed CPU time that process has used. How can I do that?

Here is how I get my PID:

Dim myproc,TheProcTime
myproc = New System.Diagnostics.Process
MyProcID = myproc.Start("c:\run27.exe", "c:\input.ini")
For 1 instance, I can find the CPU time elapsed by:

TheProcTime = MyProcID.userprocessortime.totalseconds

BUT, I cannot get this value to update with the process running.

What do I need to do to update this value?

Thanks,
Jim
Ra****@Fauske.com

Feb 10 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jim,

You need to call the process's Refresh method in order to see new
userprocessortime values.

You could use a timer to get and display the new value for as long as the
process was running.

Kerry Moorman
"ra****@fauske.com" wrote:
HI:

I have a Process ID (PID) and want to continually query how much
elapsed CPU time that process has used. How can I do that?

Here is how I get my PID:

Dim myproc,TheProcTime
myproc = New System.Diagnostics.Process
MyProcID = myproc.Start("c:\run27.exe", "c:\input.ini")
For 1 instance, I can find the CPU time elapsed by:

TheProcTime = MyProcID.userprocessortime.totalseconds

BUT, I cannot get this value to update with the process running.

What do I need to do to update this value?

Thanks,
Jim
Ra****@Fauske.com

Feb 10 '06 #2

P: n/a
Excellent! I tried it and it works!
Thanks so much,
Jim

Feb 10 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.