Occurs when a process exits.
Assembly: System (in System.dll)
The EnableRaisingEvents property is true.event indicates that the associated process exited. This occurrence means either that the process terminated (aborted) or successfully closed. This event can occur only if the value of the
There are two ways of being notified when the associated process exits: synchronously and asynchronously. Synchronous notification means calling the WaitForExit method to block the current thread until the process exits. Asynchronous notification uses the event, which allows the calling thread to continue execution in the meantime. In the latter case, EnableRaisingEvents must be set to true for the calling application to receive the Exited event.
When the operating system shuts down a process, it notifies all other processes that have registered handlers for the Exited event. At this time, the handle of the process that just exited can be used to access some properties such as ExitTime and HasExited that the operating system maintains until it releases that handle completely.
Even if you have a handle to an exited process, you cannot call Start again to reconnect to the same process. Calling Start automatically releases the associated process and connects to a process with the same file but an entirely new Handle.
For more information about the use of the SynchronizingObject property.event in Windows Forms applications, see the
The following code example creates a process that prints a file. It raises the EnableRaisingEvents property was set when the process was created. The event handler displays process information.event when the process exits because the
for full trust for the immediate caller. This member cannot be used by partially trusted code.
Available since 1.1