Process.WaitForExit() is not waiting

Viewed 31

I wrote a small method that starts a process and then should wait until the process has exited. But it's not waiting until the process has finished. "test" will be printed immediately.

This is the code:

var p = new Process();
p.StartInfo = new ProcessStartInfo(p_Path)
{
    UseShellExecute = true
};
p.Start();
p.WaitForExit();  //<- its not working
MessageBox.Show("test");

The process is an Excel document.

Thanks for your help :)

0 Answers
Related