I know how to begin a Process and how to wait it for exit but that seems that it does not work properly for resources.I have the followning lines of code
string path = @"C:\Users\%USERNAME%\AppData\Local\Temp\MyFolder";
Directory.CreateDirectory(path);
if (checkbox1.Checked)
{
var exe1 = new Resource("SOLUTION.Resources.First.exe",
Path.Combine(path, "1st.exe"));
Process.Start(exe1.FilePath);
}
if (checkbox2.Checked)
{
var exe2 = new Resource("SOLUTION.Resources.Second.exe",
Path.Combine(path, "Second.exe"));
Process.Start(exe2.FilePath);
}
But when I start the process both of them start together how to set each of them wait for the previous to be completed?
Thank you all for your support so far
You can use Process.WaitForExit()
.
string path = @"C:\Users\%USERNAME%\AppData\Local\Temp\MyFolder";
Directory.CreateDirectory(path);
if (checkbox1.Checked)
{
var exe1 = new Resource("SOLUTION.Resources.First.exe",
Path.Combine(path, "1st.exe"));
Process.Start(exe1.FilePath).WaitForExit();
}
if (checkbox2.Checked)
{
var exe2 = new Resource("SOLUTION.Resources.Second.exe",
Path.Combine(path, "Second.exe"));
Process.Start(exe2.FilePath).WaitForExit();
}