Home All Groups Group Topic Archive Search About

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

Author
10 Feb 2006 5:42 PM
raines@fauske.com
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
Rai***@Fauske.com

Author
10 Feb 2006 6:23 PM
Kerry Moorman
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


Show quoteHide quote
"rai***@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
> Rai***@Fauske.com
>
>
Author
10 Feb 2006 6:41 PM
raines@fauske.com
Excellent! I tried it and it works!
Thanks so much,
Jim