I'm writing a piece of c# code that launches an installer and waits for it to return before continuing with other stuff.
I'm having trouble with certain installers that spawn other processes with the original process returning before the install has actual finished. Is there some way that I can wait until all the processes have finished?
To clarify here's the scenario I'm having trouble with:
- Launch Installer1
- Installer1 spawns/launches another installer (Installer2)
- Installer 1 returns
- Application thinks install has finished but Installer2 is still running. This causes issues with workflow in the app.
Here's the code I'm using at the moment:
// launch installer
Process process = windowsApplicationLauncher.LaunchApplication(_localFilePath);
// wait for process to return
do
{
if (!process.HasExited)
{
}
}
while (!process.WaitForExit(1000));
if (process.ExitCode == 0)
{
_fileService.MoveFile(_localFilePath, _postInstallFilePath);
_notification.SetComplete(false);
return true;
}
return false;