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 and Close are not two options. Kill (or CloseMainWindow) must be called if you want to terminate a process. Calling Close will just free resources, but it won't close the standard streams. Closing the streams yourself may or may not cause the process to end, it depends on the process. The best strategy is to call Kill or CloseMainWindow depending on the type of process and then Dispose the Process object.
Close begins closing the Process object. It's called by Dispose. Close is generally used for managing the Process object's resources.
Kill terminates the process. This is the only way to terminate a process that has no user interface.
CloseMainWindow sends a close message to the main window of the process. This is the graceful way to stop a process that has a user interface.