C# Why does form.Close() not close the form?

The rest of the event handler is executed because you did not leave the method. It is as simple as that.

Calling this.Close() does not immediately "delete" the form (and the current event handler). The form will be collected later on by the garbage collector if there are no more references to the form.

this.Close() is nothing than a regular method call, and unless the method throws an exception you will stay in the context of your current method.


Close only hides the form; the form is still alive and won't receive another Load event if you show it again.

To actually delete it from memory, use Dispose().


Answer is simple as you are executing your current method so this.Close() will be enqueued until either you explicitly returned or your current excuting method throws an exception.

Tags:

C#

Winforms