Re: To destroy modeless form
i am new to this but i used
Re: To destroy modeless form
this.Close will close your application (by closing the main window).
form.Close() is what you're probably trying to say. it causes the form to be disposed.
if you're watching the memory window to see memory go down, it wont, this is because of the way .net operates. because you've disposed something doesnt mean its gone. there is a multi-tiered approach to garbage in .net so because you've disposed of an object doesnt mean that your application's memory usage is going to be lowered.
Re: To destroy modeless form
i used this.Close(); to close all my forms. should i be using form.Close(); instead?
Re: To destroy modeless form
he's wanting to close the form that he opened in his code sample, not to close down his whole application.
Re: To destroy modeless form
i tried to use form.Close(); and i got an error. this.Close(); works great for closing any form. it dosent close the whole application for me.
i also use the same code to open my form that nazgul27 used only i used my form names.
Re: To destroy modeless form
this.Close() works for the current window, the current context and you can use it when you have a modal dialog because you can not close it from the other dialogs. With form.Close() he ment closing one from from the other's context when you have modeless dialog. That means if you create a modeless dialog:
Code:
Form2 frm = new Form2();
frm.Show();
you can close it from another dialog ( which can get focus because we have modeless dialogs) : frm.Close().
Closing the whole application can be done with Application.Exit() or by closing the main form ( the one that is executed first in the thread from Program.cs):
Code:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
Form1 in this case.
Re: To destroy modeless form
Here is the problem. There is a webbrowser control on that modeless form, it navigates to a certain web site from time to time. Everytime it navigates the memory goes up. I described this problem in another topic though..
I don't know how to fix it rather than closing and opening the form again. But i don't know need to close it, i need the form to be destroyed totally. WebBrowser control also. and then reopen again.
there is a timer on that modeless form and here's what I noticed. If I just call:
then the timer is NOT destroyed, The application still call it and gets an exception after that.
I tried to call
Code:
form.cleanup();
form.Dispose ()
where i destroy the timer in "cleanup" function.
Anyway, this did not solve my problem. The memory is not freed. Seems like the only is to close the entire app and open it again.
Any ideas please:)
Re: To destroy modeless form
Remember that memory management in managed code is quite different.
Even if memory is "freed", it is not directly returned to the operating system. Therefore if you use tools like task manager you will get mis-leading information.
The only (neglecting 3rd party tools) way to see what is going on is to use Performance Monitor.