Results 1 to 6 of 6

Thread: Process.WaitforExit

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262

    Process.WaitforExit

    Has anyone had any success using this?

    I have the following code

    Code:
    			try
    			{
    				//Here we just need to shell the Dirver installation
    				Process Proc = new Process();
    				//I dont need to know when we are done
    				Proc.EnableRaisingEvents=false;
    				//Get it set up
    				Proc.StartInfo.Arguments = "REDISTRIBUTION RESPONSEFILE=\"" +
    					Environment.CurrentDirectory.ToString() + "\\Drivers\\response.txt\"" ;
    				Proc.StartInfo.FileName = Environment.CurrentDirectory.ToString()
    					+  "\\Drivers\\redist.exe";
    
    				//Launch install
    				Proc.Start();
    				Proc.WaitForExit();
    			}
    			catch ( System.ComponentModel.Win32Exception )
    			{
    				//If we come in here, we had an error
    				MessageBox.Show(this,"Main Menu could not find the " +
    					"video card driver setup file. Please " +
    					"check to ensure the CD is installed " +
    					"in the CD-ROM.","Error Reading CD", 
    					MessageBoxButtons.OK, MessageBoxIcon.Information);
    										
    			}
    It hangs will not always launch my app. If it does launch the app, then when the new process exits, it does not restore itself and hangs up.

    Thanks for your help,

    Jerel

  2. #2
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    what are you trying to acomplish? you are not doing nothing after the other app gives focus again to your app
    \m/\m/

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262
    This code is duplicated a few times in the program, not the best program layout but I took it out here for somereason when I pasted it.

    After the process I spawn ends, I either need to reboot the computer or launch the program manual which happens to be in adobe.

    So in one part of the program, I try to launch a program manual, if I dont detect adobe, I spawn the adobe install, I want to wait until the intstall is complete, then spawn the manual.

    Does that make sense?

    Jerel

  4. #4
    yay gay PT Exorcist's Avatar
    Join Date
    Apr 2002
    Location
    . . . my reason of shame
    Posts
    2,729
    yes but what are you doing after
    Proc.Start();
    Proc.WaitForExit();
    ?
    \m/\m/

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262
    I dont have anything after them, do I have to have something after the waitforexit for it to operate correctly?

    The main point for having them wait is, this app is a main menu for a CD. It autoruns and the user can install the program, adobe, or some video card drivers. I dont want them to choose more than one option and also I need to reboot after they install the drivers.

    So there are three places where I wait, It could be more efficient I know, just trying to get it all to work first. One of the place, which is what I posted here, needs to rebot the machine. I have not written that code yet.

  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    Jun 2002
    Location
    Tulsa,Ok
    Posts
    262
    This fixed the problem. I added one line WaitForIdleInput.

    This line will wait until the given process is waiting for user input with no input pending, per the definition. I actually noticed when you launch older versions of InstallShield, especially Adobe, if I did not add this line, the shelling of the program would hang at 99%. Not sure what the installer is doing, but adding this line fixed the problem.

    Code:
    			try
    			{
    				//Here we just need to shell the Dirver installation
    				Process Proc = new Process();
    				//I dont need to know when we are done
    				Proc.EnableRaisingEvents=false;
    				//Get it set up
    				Proc.StartInfo.Arguments = "REDISTRIBUTION RESPONSEFILE=\"" +
    					Environment.CurrentDirectory.ToString() + "\\Drivers\\response.txt\"" ;
    				Proc.StartInfo.FileName = Environment.CurrentDirectory.ToString()
    					+  "\\Drivers\\redist.exe";
    
    				//Launch install
    				Proc.Start();
                                    Proc.WaitForIdleInput();
    				Proc.WaitForExit();
    			}
    			catch ( System.ComponentModel.Win32Exception )
    			{
    				//If we come in here, we had an error
    				MessageBox.Show(this,"Main Menu could not find the " +
    					"video card driver setup file. Please " +
    					"check to ensure the CD is installed " +
    					"in the CD-ROM.","Error Reading CD", 
    					MessageBoxButtons.OK, MessageBoxIcon.Information);
    										
    			}
    Jerel

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