Replace the loop that waits for the output file to exist, with a call to the Process.WaitForExit() method with a time-out.