Re: Creating a process in ASP.NET and checking TotalProcessorTime
From: Juerg Staub (juerg.staub@object-soft.ch)
Date: 08/20/02
- Next message: Patrick Long: "Cookie Encryption and custom auth"
- Previous message: Oran: "Vague security error - Write permissions"
- In reply to: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Next in thread: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Reply: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
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.
- Next message: Patrick Long: "Cookie Encryption and custom auth"
- Previous message: Oran: "Vague security error - Write permissions"
- In reply to: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Next in thread: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Reply: Mike Moore [MS]: "Re: Creating a process in ASP.NET and checking TotalProcessorTime"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] [ attachment ]
Relevant Pages
|