At a certain point in my program I need to launch a program [oApp.exe] with a specific command line parameter.
To accomplish this I used the Process class as shown in the code below:
This will launch oApp.exe (with command line parameter C:\Text.txt) which should take 5-10mins to process.
Problem is, I want my code to WAIT for this process to complete/finsish (the 5-10mins) before going forward seeing as the next line of code assumes that the Text.txt was processed.
The way it is now, the process is launched and them my code continues (it does not wait) which consequently causes a huge amount of fatal errors further down.
So, how do I WAIT for my Process to complete? Do I have to actually make a Process variable?
But that also doesn't WAIT - however I assume it gives us more control....
Any help/hints would be much appreciated. Thanks,
To accomplish this I used the Process class as shown in the code below:
Code:
Process.Start("oApp.exe", "c:\\text.txt");
This will launch oApp.exe (with command line parameter C:\Text.txt) which should take 5-10mins to process.
Problem is, I want my code to WAIT for this process to complete/finsish (the 5-10mins) before going forward seeing as the next line of code assumes that the Text.txt was processed.
The way it is now, the process is launched and them my code continues (it does not wait) which consequently causes a huge amount of fatal errors further down.
So, how do I WAIT for my Process to complete? Do I have to actually make a Process variable?
Code:
Process pApp = new Process();
pApp.StartInfo.FileName = "oApp.exe";
pApp.StartInfo.Arguments = "C:\\text.txt";
pApp.Start();
But that also doesn't WAIT - however I assume it gives us more control....
Any help/hints would be much appreciated. Thanks,