Close & Dispose

  • Thread starter Thread starter Tim Bücker
  • Start date Start date
T

Tim Bücker

I´ve got a little program with the "x" in the upper right corner and a menu item "close" to do the same - end the program.

The problem now is that using my program it gets sometimes impossible to end the program. Clicking the "x" nothing happens and
calling
this.Close();
when the menu item "close" is pressed also doesn´t change anything.

But calling
this.Close();
this.Dispose();
when the user clicks the menu item, the program is shut down!

I´ve checked my program for any infinite loops but I didn´t find anything.
Does someone have an idea where to look else to resolve such kind of problem?

Any help is welcome.
Thanks and greetings,
Tim.
 
Tim,

Do you have code that hooks up to the Closing event? Is it possible
that you are cancelling the closing in the event somehow (assuming you hook
up to it)?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Tim Bücker said:
I´ve got a little program with the "x" in the upper right corner and a
menu item "close" to do the same - end the program.
The problem now is that using my program it gets sometimes impossible to
end the program. Clicking the "x" nothing happens and
 
Nicholas Paldino said:
Do you have code that hooks up to the Closing event? Is it possible
that you are cancelling the closing in the event somehow (assuming you hook
up to it)?

Thanks for answering!
I didn´t hook up the closing event but I´ve inserted some custom controls in
my form - one custom control consisting of TextBox, Label1 and Label2.

Removing them from the form and adding them later again I forget to dispose
these objects and due to that I couldn´t close my program (although I don´t
understand 100% why a program halts in this case as the garbage collector
should take care of this - probably too slow...)

Thanks again for answering!
Greetings,
Tim.
 
Back
Top