As is asked in this post, there are two ways to call another process in C#.
Process.Start("hello");
And
Process p = new Process();
p.StartInfo.FileName = "hello.exe";
p.Start();
p.WaitForExit();
- Q1 : What are the pros/cons of each approach?
- Q2 : How to check if error happens with the
Process.Start()
method?
With the first method you might not be able to use
WaitForExit
, as the method returns null if the process is already running.How you check if a new process was started differs between the methods. The first one returns a
Process
object ornull
:The second one returns a
bool
: