What are the differences between kill process and close process?

后端 未结 5 732
北荒
北荒 2020-12-13 07:59

When I start a process and want to close this process, what are the differences between Process.Close() and Process.Kill()?

I asked because

5条回答
  •  抹茶落季
    2020-12-13 08:53

    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.

提交回复
热议问题