You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add documentation for Process.Kill(bool entireProcessTree) (#2828)
* Add documentation for Process.Kill(bool entireProcessTree)
* Update Process.xml
* minor fix: parm summary in single line
* Address feedback
* Address Feedback
* Fixed bad xml element
When a process is executing, its message loop is in a wait state. The message loop executes every time a Windows message is sent to the process by the operating system. Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close to the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit. The application can ask for user verification before quitting, or it can refuse to quit. To force the application to quit, use the <xref:System.Diagnostics.Process.Kill%2A> method. The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
708
+
When a process is executing, its message loop is in a wait state. The message loop executes every time a Windows message is sent to the process by the operating system. Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit. The application can ask for user verification before quitting, or it can refuse to quit. To force the application to quit, use the <xref:System.Diagnostics.Process.Kill%2A> method. The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
709
709
710
710
Data edited by the process or resources allocated to the process can be lost if you call <xref:System.Diagnostics.Process.Kill%2A>. <xref:System.Diagnostics.Process.Kill%2A> causes an abnormal process termination, and should be used only when necessary. <xref:System.Diagnostics.Process.CloseMainWindow%2A> enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface. If <xref:System.Diagnostics.Process.CloseMainWindow%2A> fails, you can use <xref:System.Diagnostics.Process.Kill%2A> to terminate the process. <xref:System.Diagnostics.Process.Kill%2A> is the only way to terminate processes that do not have graphical interfaces.
711
711
@@ -2054,6 +2054,49 @@ There are problems accessing the performance counter API's used to get process i
The `Kill` method forces a termination of the process, while <xref:System.Diagnostics.Process.CloseMainWindow%2A> only requests a termination.
2066
+
When a process with a graphical interface is executing, its message loop is in a wait state.
2067
+
The message loop executes every time a Windows message is sent to the process by the operating system.
2068
+
Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application.
2069
+
The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit.
2070
+
The application can ask for user verification before quitting, or it can refuse to quit.
2071
+
To force the application to quit, use the `Kill` method.
2072
+
2073
+
The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu.
2074
+
Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
2075
+
2076
+
> [!NOTE]
2077
+
> The <xref:System.Diagnostics.Process.Kill%2A> method executes asynchronously.
2078
+
> After calling the `Kill` method, call the <xref:System.Diagnostics.Process.WaitForExit%2A> method to wait for the process to exit, or check the <xref:System.Diagnostics.Process.HasExited%2A> property to determine if the process has exited.
2079
+
2080
+
> [!NOTE]
2081
+
> The <xref:System.Diagnostics.Process.WaitForExit%2A> method and the <xref:System.Diagnostics.Process.HasExited%2A> property do not reflect the status of descendant processes.
2082
+
> When `Kill(entireProcessTree: true)` is used, <xref:System.Diagnostics.Process.WaitForExit%2A> and <xref:System.Diagnostics.Process.HasExited%2A> will indicate that exiting has completed after the given process exits, even if all descendants have not yet exited.
2083
+
2084
+
Data edited by the process or resources allocated to the process can be lost if you call `Kill`.
2085
+
`Kill` causes an abnormal process termination and should be used only when necessary.
2086
+
<xref:System.Diagnostics.Process.CloseMainWindow%2A> enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface.
2087
+
If <xref:System.Diagnostics.Process.CloseMainWindow%2A> fails, you can use `Kill` to terminate the process.
2088
+
`Kill` is the only way to terminate processes that do not have graphical interfaces.
2089
+
2090
+
You can call `Kill` and <xref:System.Diagnostics.Process.CloseMainWindow%2A> only for processes that are running on the local computer.
2091
+
You cannot cause processes on remote computers to exit. You can only view information for processes running on remote computers.
2092
+
2093
+
> [!NOTE]
2094
+
> If the call to the `Kill` method is made while the process is currently terminating, a <xref:System.ComponentModel.Win32Exception> is thrown for Access Denied.
@@ -2086,33 +2129,12 @@ There are problems accessing the performance counter API's used to get process i
2086
2129
<Parameters />
2087
2130
<Docs>
2088
2131
<summary>Immediately stops the associated process.</summary>
2089
-
<remarks>
2090
-
<format type="text/markdown"><![CDATA[
2091
-
2092
-
## Remarks
2093
-
<xref:System.Diagnostics.Process.Kill%2A> forces a termination of the process, while <xref:System.Diagnostics.Process.CloseMainWindow%2A> only requests a termination. When a process with a graphical interface is executing, its message loop is in a wait state. The message loop executes every time a Windows message is sent to the process by the operating system. Calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> sends a request to close to the main window, which, in a well-formed application, closes child windows and revokes all running message loops for the application. The request to exit the process by calling <xref:System.Diagnostics.Process.CloseMainWindow%2A> does not force the application to quit. The application can ask for user verification before quitting, or it can refuse to quit. To force the application to quit, use the <xref:System.Diagnostics.Process.Kill%2A> method. The behavior of <xref:System.Diagnostics.Process.CloseMainWindow%2A> is identical to that of a user closing an application's main window using the system menu. Therefore, the request to exit the process by closing the main window does not force the application to quit immediately.
2094
-
2095
-
> [!NOTE]
2096
-
> The <xref:System.Diagnostics.Process.Kill%2A> method executes asynchronously. After calling the <xref:System.Diagnostics.Process.Kill%2A> method, call the <xref:System.Diagnostics.Process.WaitForExit%2A> method to wait for the process to exit, or check the <xref:System.Diagnostics.Process.HasExited%2A> property to determine if the process has exited.
2097
-
2098
-
Data edited by the process or resources allocated to the process can be lost if you call <xref:System.Diagnostics.Process.Kill%2A>. <xref:System.Diagnostics.Process.Kill%2A> causes an abnormal process termination and should be used only when necessary. <xref:System.Diagnostics.Process.CloseMainWindow%2A> enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface. If <xref:System.Diagnostics.Process.CloseMainWindow%2A> fails, you can use <xref:System.Diagnostics.Process.Kill%2A> to terminate the process. <xref:System.Diagnostics.Process.Kill%2A> is the only way to terminate processes that do not have graphical interfaces.
2099
-
2100
-
You can call <xref:System.Diagnostics.Process.Kill%2A> and <xref:System.Diagnostics.Process.CloseMainWindow%2A> only for processes that are running on the local computer. You cannot cause processes on remote computers to exit. You can only view information for processes running on remote computers.
2101
-
2102
-
> [!NOTE]
2103
-
> If the call to the <xref:System.Diagnostics.Process.Kill%2A> method is made while the process is currently terminating, a <xref:System.ComponentModel.Win32Exception> is thrown for Access Denied.
2104
-
2105
-
]]></format>
2106
-
</remarks>
2132
+
<remarks>To be added.</remarks>
2107
2133
<exception cref="T:System.ComponentModel.Win32Exception">The associated process could not be terminated.
2108
2134
2109
2135
-or-
2110
2136
2111
-
The process is terminating.
2112
-
2113
-
-or-
2114
-
2115
-
The associated process is a Win16 executable.</exception>
2137
+
The process is terminating.</exception>
2116
2138
<exception cref="T:System.NotSupportedException">You are attempting to call <see cref="M:System.Diagnostics.Process.Kill" /> for a process that is running on a remote computer. The method is available only for processes running on the local computer.</exception>
2117
2139
<exception cref="T:System.InvalidOperationException">The process has already exited.
2118
2140
@@ -2150,9 +2172,29 @@ There are problems accessing the performance counter API's used to get process i
<param name="entireProcessTree">To be added.</param>
2154
-
<summary>To be added.</summary>
2155
-
<remarks>To be added.</remarks>
2175
+
<param name="entireProcessTree"><see langword="true" /> to kill the associated process and its descendants; <see langword="false" /> to kill only the associated process.</param>
2176
+
<summary>Immediately stops the associated process, and optionally its child/descendent processes.</summary>
2177
+
<remarks>When <paramref name="entireProcessTree" /> is set to <see langword="true" />, processes where the call lacks permissions to view details are silently skipped by the descendant termination process because the termination process is unable to determine whether those processes are descendants.</remarks>
2178
+
<exception cref="T:System.ComponentModel.Win32Exception">The associated process could not be terminated.
2179
+
2180
+
-or-
2181
+
2182
+
The process is terminating.</exception>
2183
+
<exception cref="T:System.NotSupportedException">You are attempting to call <see cref="M:System.Diagnostics.Process.Kill" /> for a process that is running on a remote computer. The method is available only for processes running on the local computer.</exception>
2184
+
<exception cref="T:System.InvalidOperationException">The process has already exited.
2185
+
2186
+
-or-
2187
+
2188
+
There is no process associated with this <see cref="T:System.Diagnostics.Process" /> object.
2189
+
2190
+
-or-
2191
+
2192
+
The calling process is a member of the associated process' descendant tree.</exception>
2193
+
<exception cref="T:System.AggregateException">Not all processes in the associated process' descendant tree could be terminated.</exception>
2194
+
<permission cref="F:System.Security.Permissions.SecurityAction.LinkDemand">for full trust for the immediate caller. This member cannot be used by partially trusted code.</permission>
0 commit comments