Results 1 to 2 of 2

Thread: Exited event of a Process probs

  1. #1

    Thread Starter
    Fanatic Member venerable bede's Avatar
    Join Date
    Sep 2002
    Location
    The mystic land of Geordies
    Posts
    1,018

    Exited event of a Process probs

    I start a new process which in this case will be IE with the following code :
    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 ?

    Parksie

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Exited event of a Process probs

    It's not really that strange, but it is inconvenient. When you call Process.Start you start a process. It's not necessarily that process that you see running though. If you start IE and it starts Word then IE will have already exited before the Start method returns, thus no Exited event will ever be raised. The Word process is not in any way linked to your Process object. The same can be true with tabbed browsers if a window is already open. The browser may create a new tab in the existing process rather than start another.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width