C# Programming
06-14-2009, 01:00 PM
Hi
I have a Windows form called mainwindow in my project. After it completes what it does, it closes and then recreates itself. But as I have noticed lately it recreates but doesnt't close itself.
Here is my code:
private void RestartAll()
{
// These are not that important, only to transfer the same properties of the form to the new form.
depo.multipleform********=this.********;
depo.multipleform = true;
depo.ekrangoruntusuadedi = 0;
this.Hide();
mainwindow _mainwindow = new mainwindow();
_main********ShowDialog();
this.Close();
// Here is my temporary solution (putting old form's thread to sleep infinitely because it shouldn't keep doing what it does)
Thread.Sleep(Timeout.Infinite);
}
How can I close(destroy) the old form completely and recreate that form? When I don't completely close that old form, because I do this closing and recreating process more than once my App's memory usage gets much higher.
Thanks in advance.
I have a Windows form called mainwindow in my project. After it completes what it does, it closes and then recreates itself. But as I have noticed lately it recreates but doesnt't close itself.
Here is my code:
private void RestartAll()
{
// These are not that important, only to transfer the same properties of the form to the new form.
depo.multipleform********=this.********;
depo.multipleform = true;
depo.ekrangoruntusuadedi = 0;
this.Hide();
mainwindow _mainwindow = new mainwindow();
_main********ShowDialog();
this.Close();
// Here is my temporary solution (putting old form's thread to sleep infinitely because it shouldn't keep doing what it does)
Thread.Sleep(Timeout.Infinite);
}
How can I close(destroy) the old form completely and recreate that form? When I don't completely close that old form, because I do this closing and recreating process more than once my App's memory usage gets much higher.
Thanks in advance.