Control the behaviour of spawned process

Posted on 2007-10-16
Last Modified: 2013-11-26
I want to start a new process and wait for it to finish processing and quit before I continue from the main process. Any advice on how to achieve this?

Question by:sepknow
    LVL 20

    Assisted Solution

    you have the event exited.


                System.Diagnostics.Process p = new System.Diagnostics.Process();
                p.Exited += new EventHandler(p_Exited);

        void p_Exited(object sender, EventArgs e)
            throw new Exception("The method or operation is not implemented.");

    You could simply put in a waithandle and signal it once that event fires.  You can also check the exit code.

    LVL 11

    Accepted Solution

    Process.WaitForExit () is the function you need to look for ( without wait time)

    Best Regards,

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
    Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video discusses moving either the default database or any database to a new volume.

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now