In the following example, what happens to the process if it is still running once the code leaves the using statement?
using (var p = new Process())
{
p.StartInfo.FileName = "c:\\temp\\SomeConsoleApp.exe";
p.Start();
}
One should separate the OS process that is running on your system from the Process
object that represents a "handle" to it in your program:
Process
object gets disposed, so your program can no longer interact with the OS process.Call of Dispose()
method on the Process
object does not kill the OS process.