Actually, in your code above, the condition will still be evaluated. Application.Exit() does NOT immediately and unconditionally kill the program. Rather, it puts a message in the message pump that requests a shutdown. The remainder of the function will continue to execute (assuming that it's executing on the same thread as the message pump) since the message can't be processed until the currently executing function returns. Only when the message pump next checks for messages will the program shut down.
Example: The following DOES write the line of text to the log:
You probably could do a scorched-earth method like get a handle to the current process and kill it, but that's CERTAINLY not good practice.Code:StreamWriter loggingFile = new StreamWriter(@"outputLog.txt"); /* ... */ Application.Exit(); loggingFile.WriteLine("Exit has been called"); loggingFile.Close();