Este artículo se tradujo automáticamente. Para ver el artículo en inglés, active la casilla Inglés. Además, puede mostrar el texto en inglés en una ventana emergente si mueve el puntero del mouse sobre el texto.
Traducción
Inglés

Método Process.Kill ()

 

Detiene inmediatamente el proceso asociado.

Espacio de nombres:   System.Diagnostics
Ensamblado:  System (en System.dll)

public void Kill()

Exception Condition
Win32Exception

No se pudo terminar el proceso asociado.

-o-

El proceso está finalizando.

O bien

El proceso asociado es un ejecutable de Win16.

NotSupportedException

Está intentando llamar a Kill para un proceso que se ejecuta en un equipo remoto. El método está disponible solo para los procesos que se ejecutan en el equipo local.

InvalidOperationException

El proceso ya se cerró.

-o-

No hay ningún proceso asociado a este objeto Process.

Kill forces a termination of the process, while CloseMainWindow 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 CloseMainWindow 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 CloseMainWindow 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 Kill method. The behavior of CloseMainWindow 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.

System_CAPS_noteNota

The M:System.Diagnostics.Process.Kill method executes asynchronously. After calling the M:System.Diagnostics.Process.Kill method, call the Overload:System.Diagnostics.Process.WaitForExit method to wait for the process to exit, or check the P:System.Diagnostics.Process.HasExited property to determine if the process has exited.

Data edited by the process or resources allocated to the process can be lost if you call M:System.Diagnostics.Process.Kill. M:System.Diagnostics.Process.Kill causes an abnormal process termination and should be used only when necessary. M:System.Diagnostics.Process.CloseMainWindow enables an orderly termination of the process and closes all windows, so it is preferable for applications with an interface. If M:System.Diagnostics.Process.CloseMainWindow fails, you can use M:System.Diagnostics.Process.Kill to terminate the process. M:System.Diagnostics.Process.Kill is the only way to terminate processes that do not have graphical interfaces.

You can call M:System.Diagnostics.Process.Kill and M:System.Diagnostics.Process.CloseMainWindow 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.

System_CAPS_noteNota

If the call to the M:System.Diagnostics.Process.Kill method is made while the process is currently terminating, a T:System.ComponentModel.Win32Exception is thrown for Access Denied.

LinkDemand

for full trust for the immediate caller. This member cannot be used by partially trusted code.

.NET Framework
Disponible desde 1.1
Volver al principio
Mostrar: