NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Process.ExitCode

Gets the value that was specified by the associated process when it was terminated.

[Visual Basic]
Public ReadOnly Property ExitCode As Integer
[C#]
public int ExitCode {get;}
[C++]
public: __property int get_ExitCode();
[JScript]
public function get ExitCode() : int;

Property Value

The code specified by the associated process when the process was terminated. A successful exit returns zero (0).

Exceptions

Exception Type Condition
InvalidOperationException The process has not been exited.

-or-

The process Handle is not valid.

Remarks

Use ExitCode to get the status returned when the system process exited. You can write your code to return any value to the calling method, and handle value in your code, much like an integer return value for a Main procedure. Indicate a successful exit by an ExitCode value of zero, and errors by non-zero values which your calling method can use to identify the cause of an abnormal process termination. It is not necessary to follow these guidelines, but usually developers follow the convention.

See TBD in the Platform SDK for a list of common HRESULT values and the associated error conditions.

If you try to get the ExitCode before System.Diagnostics.Process.Exited is true, an exception will be thrown. Examine the System.Diagnostics.Process.Exited property first to verify whether the process for which you are retrieving the exit code has been terminated.

You can use the CloseMainWindow or Kill methods to cause an associated process to exit. If the process is running asynchronously, WatchForExit must be set to true for the Process component to receive notification that the process has exited. If the process is running synchronously with your application, WaitForExit pauses processing until the associated component exits.

See Also

Process Class | Process Members | System.Diagnostics Namespace | HasExited | CloseMainWindow | Kill | WaitForExit | WatchForExit