Re: Creating a process in ASP.NET and checking TotalProcessorTime

From: Juerg Staub (juerg.staub@object-soft.ch)
Date: 08/20/02


From: juerg.staub@object-soft.ch (Juerg Staub)
Date: 20 Aug 2002 01:16:20 -0700


Hi Mike,

I am not accessing these properties in the exit handler. I am
accessing them when the process ist still running.

Thanks

Juerg

michmo@online.microsoft.com (Mike Moore [MS]) wrote in message news:<hMELKD9RCHA.1108@cpmsftngxa07>...
> Hi Juerg,
>
> QUESTION
> I am creating a process in a C# class like the following:
>
> code> ProcessStartInfo sti = new ProcessStartInfo();
> code> sti.FileName = "c:\\windows\\notepad.exe";
> code> sti.CreateNoWindow = true;
> code> sti.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
> code> this.process = Process.Start(sti);
> code> this.process.Exited += new EventHandler(this.processDied);
>
> When I try to get the processor time with
>
> code> TimeSpan ts = this.process.TotalProcessorTime
>
> I receive a System.InvalidOperation exeception. The process is created
> as the NETWORK SERVICE user. I tried with impersonate and/or changing
> the processModel user to system with no help. The notepad.exe is only
> an example. The real process will be a windowless program.
>
> The box is .NET server with IIS6.
>
>
> FURTHER
> I previously answered that you needed to set another process object
> property: EnableRaisingEvents = True. However, you wrote back that your
> exit event handler was working, even without this property enabled. You
> added that, within the exit process event, you could access some of the
> process object's properties, but not all of them, presumably due to
> security settings.
>
>
> ANSWER
> I saw an easy answer & just gave that to you without properly
> investigating. Sorry about that. Here's some better information.
>
> Some process properties are only available when the process is still
> running. TotalProcessorTime is one of these properties. Trying the same
> code from a standard EXE reveals more information. Trying to access the
> TotalProcessorTime property in the exited event using a standard EXE
> results in this error:
> * Error
> An unhandled exception of type 'System.InvalidOperationException'
> occurred in system.dll
> Additional information: Process has exited, so the requested
> information is not available.
>
> For more information, please see this MSDN documentation.
>
> * Process in general
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemdiagnosticsprocessmemberstopic.asp
> - If the TreeView on the left is NOT visible, click "show toc" (table of
> contents) at the top of the page
> - At the top of the TreeView on the left, click "sync toc"
> - Within the toc, expand the section for "Process" to see various useful
> info on this topic.
>
> * TotalProcessorTime
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
> frlrfsystemdiagnosticsprocessmemberstopic.asp
> - This is a sub-item in the "toc" underneath Process - Properties
> This page shows sample code which periodically (once per second) retrieves
> the value of TotalProcessorTime so long as the process has not exited and
> is still responding.
>
>
> -----
> About the beta for Win .NET
> I still haven't heard back from my inquiries about where to send questions
> related to the beta. If you need this information, please repost and I will
> look further.
>
>
> Thank you, Mike Moore
> Microsoft, ASP.NET
>
> This posting is provided "AS IS" with no warranties, and confers no rights.



Relevant Pages

  • Re: incorporating new ideas
    ... forced his way through the scrum and pelted down the corridor to the exit. ... He heard a yell from behind him as Barker was still fighting his way out, ... Mike had been bullied ... at school all his life but Barker was one of the worst. ...
    (rec.arts.sf.composition)
  • Re: incorporating new ideas
    ... forced his way through the scrum and pelted down the corridor to the exit. ... Mike had been bullied ... at school all his life but Barker was one of the worst. ... warning the kids not go across the common unaccompanied. ...
    (rec.arts.sf.composition)
  • Re: BugLet? Short Circuits
    ... "Mike" wrote in message ... exit while ... does not work (short circuit) and must be like this: ... What compiler options and version are you using to get this to compile? ...
    (microsoft.public.dotnet.languages.vb)
  • Re: a little help please
    ... Mike B wrote: ... the clear and exit are fairly simple, ... > You can parse the String into an int. ... It is a method of the Integer class, ...
    (comp.lang.java.help)
  • [PATCH 14/37] KVM: VMX: Prevent exit handler from running if emulating due to invalid state
    ... Fix by moving the clearing of the emulation_required flag to the exit handler. ... This way the exit handler can notice that we've been emulating and abort ... * to sync with guest real CR3. ...
    (Linux-Kernel)