我知道如何开始一个进程以及如何等待它退出但是它似乎无法正常运行资源。我有以下代码行
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);
}
但是当我开始这个过程时,他们两个一起开始如何设置他们每个人等待前一个完成?
感谢大家到目前为止的支持
答案 0 :(得分:0)
您可以使用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();
}