When I start a process and want to close this process, what are the differences between Process.Close()
and Process.Kill()
?
I asked because
Kill
asks the system to unceremoniously terminate the process (via a call to the Windows TerminateProcess system call). This is akin to End Process in Task Manager.
Close closes the handle to the process in .NET, but does not actually touch the process itself. Close
is also called by Dispose
. See this answer by Jon Skeet.
A third option is CloseMainWindow, which does gracefully shut down the program by asking the primary window to close. This is akin to right-clicking the program on the task bar and choosing Close.