I need my application (Master) to run another application (Worker) on a particular event.
If I distribute my Worker application as a standard executable, then all is well, and I can use Process.Start with no problems and happily pass in arguments and call WaitForExit.
If I distribute my Worker application as a ClickOnce Application, it creates an Application Reference, which I can start with Process.Start (once I put a copy of it in the same directory as my Master.exe), but I cannot pass it arguments or use WaitForExit.
I want to be able to do both. I suspect the call to the reference starts another process which the Worker executable actually runs in.
My code:
// This works as I expect, and returns a valid Process.
Process p0 = Process.Start("Worker.exe", "DoSomeMagic");
// This seems to work, but returns null.
Process p1 = Process.Start("Worker.appref-ms");
// This also returns null, but does not pass the argument to Worker.
Process p2 = Process.Start("Worker.appref-ms", "DoSomeMagic");
My question:
How do I do this "properly"?