exited event on process
I start a new process which in this case will be IE with the following
code :
p = new Process();
p.EnableRaisingEvents = true;
p.Exited += new EventHandler(p_Exited);
p.StartInfo.FileName = tempFilename;// mydoc.xml
p.StartInfo.CreateNoWindow = false; p.Start();
I have noticed an unusual behaviour.
For some strange reason the Exited event is fired straight after IE
opens and not just when I exit. I have also noticed that when the file
type is a .doc file resulting in Word opening the Exit event doesn't
fire at all. Even when exiting Word.
To make things wierder, if I try an excel file Excel opens fine and
fires the event at the correct time.
Has anyone come across this strange behaviour ?
Date:Thu, 09 Aug 2007 05:21:40 -0700
Author:
|
Re: exited event on process
bede wrote:
> [...]
> For some strange reason the Exited event is fired straight after IE
> opens and not just when I exit. I have also noticed that when the file
> type is a .doc file resulting in Word opening the Exit event doesn't
> fire at all. Even when exiting Word.
>
> To make things wierder, if I try an excel file Excel opens fine and
> fires the event at the correct time.
>
> Has anyone come across this strange behaviour ?
I don't have a specific answer. But do note that you are not specifying
the name of an executable file, so you are at the mercy of whatever
mechanism by which the document is mapped to a process.
Personally, I would expect _all_ of your scenarios to result in an exit
notification once the actual application has been started. As in the
way that it works when the document is opened by IE. However, it's not
unreasonable to imagine that other document types involve slightly
different mapping to the application, and thus slightly different behavior.
If you want a reliable method, I think you will need to somehow map the
document to the application itself, and make sure that you are starting
the application directly, via the executable name and whatever
parameters are necessary. Alternatively, it may be that there is some
OLE mechanism by which you can open the document as an object rather
than a process, effectively acting as a container for an embedded
document. That may work as well.
Pete
Date:Thu, 09 Aug 2007 10:04:28 -0700
Author:
|