Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

This is probably too little to go on for a definitive answer, but in looking over some legacy code, I found this (a previous peruser commented "Why?") in what serves as the main form in a Windows CE / .NET 1.1 project (Windows Forms style app_:

protected override void Dispose( bool disposing )
            base.Dispose( disposing );
            Application.Exit();         // Why?

Is calling Application.Exit() valid here? Is there any reason for it? If not, any harm in it?

share|improve this question
Probably a wrong site; also Application.Exit() is usually indeed very bad, particularly in the middle of Dispose. If a form needs to close with or without a status, then there are much better ways of doing this. –  Leonid Feb 26 '13 at 0:02
@Leonid wrong site, indeed - I'd submit this one to Daily WTF. –  Jesse C. Slicer Feb 26 '13 at 0:05

1 Answer 1

Just to elaborate on comments to question: The purpose of Dispose is to release resources owned by object (and primary purpose is to release unmanaged resources). As such Dispose method should not touch or perform action not related to the object being disposed, and Application.Exit is definitely out of scope here.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.