I am starting an application with parameteres, and I want to close my C# application after "Startup.exe" closed. After startup.exe closed the C# application still running, so my question is why WaitForExit() not working for me? And how to solve this issue?
private void button4_Click(object sender, EventArgs e)
{
string arg0 = "/connect";
string arg1 = txtUsername.Text;
string arg2 = txtPassword.Text;
string genArgs = arg0+" "+arg1 +" "+ arg2;
string pathToFile = System.IO.Directory.GetCurrentDirectory()+"/Startup.exe";
Process runProg = new Process();
runProg.StartInfo.FileName = pathToFile;
runProg.StartInfo.Arguments = genArgs;
runProg.Start();
runProg.WaitForExit();
}