Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

How to: Get and Set the Application Exit Code

This example shows how to get and set the application exit code.


Application automatically returns an exit code value to the operating system when the application stops running. Exit codes are most often used by applications to communicate the reason they stopped running to the operating system, or to other running applications.

The default exit code value that is returned by Application is 0. You can get the exit code value by handling Exit and inspecting the ApplicationExitCode property:

int exitCode = e.ApplicationExitCode;

You can change the exit code value from the default by setting ApplicationExitCode, or by calling Shutdown:

e.ApplicationExitCode = 11;


Community Additions

© 2015 Microsoft