tags:

views:

385

answers:

1

Hi I am trying to do the following : I have a process this process can take parameters (digits) and return the sum of this numbers

Process P = Process.Start(sPhysicalFilePath, Param);
                int result = P.ExitCode;

I get the return value from "ExitCode" the problem is : the program sometimes finish his work before the process so when the program reach the line

int result = P.ExitCode;

I have an exception My question is how to wait this Process until it finish its work sorry I forget to say that's I am working with C# language

+6  A: 

use:

Process P = Process.Start(sPhysicalFilePath, Param);
P.WaitForExit();
int result = P.ExitCode;

from MSDN

snicker
Thanks a lot snickerI think this what I was looking for
Hany
no problemo hombre.
snicker