C# Open a form from another form (too much processing memory)
up vote
-2
down vote
favorite
I have been looking for some time on ways to open a second form from another already shown form.
This is some piece of code that works:
frmSecond second = new frmSecond();
this.Hide();
second.ShowDialog();
this.Close();
What it does basically is to Hide() the currently opened form, then it opens another form (the ShowDialog() method). It will only Close() the currently hidden form when the form you have just created is closed.
The problem here is: this way of doing it creates an immense thread of forms. If I need to go from frmSecond to frmThird, it will maintain the first form and the frmSecond being executed in the background, while only showing the frmThird.
Then, as the frmThird is open, if I need to get back to the first form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
And it would create another frmFirst! Then we would have three forms being executed in the background (the first frmFirst, frmSecond, and frmThird).
This method works, but uses an increasingly amount of processing memory, which may be prejudicial for any kind of project.
Is there any alternative or add up to correct this problem?
If anything is unclear, please don't bother in letting me know.
Thank you.
c# .net winforms
|
show 1 more comment
up vote
-2
down vote
favorite
I have been looking for some time on ways to open a second form from another already shown form.
This is some piece of code that works:
frmSecond second = new frmSecond();
this.Hide();
second.ShowDialog();
this.Close();
What it does basically is to Hide() the currently opened form, then it opens another form (the ShowDialog() method). It will only Close() the currently hidden form when the form you have just created is closed.
The problem here is: this way of doing it creates an immense thread of forms. If I need to go from frmSecond to frmThird, it will maintain the first form and the frmSecond being executed in the background, while only showing the frmThird.
Then, as the frmThird is open, if I need to get back to the first form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
And it would create another frmFirst! Then we would have three forms being executed in the background (the first frmFirst, frmSecond, and frmThird).
This method works, but uses an increasingly amount of processing memory, which may be prejudicial for any kind of project.
Is there any alternative or add up to correct this problem?
If anything is unclear, please don't bother in letting me know.
Thank you.
c# .net winforms
you could useusing(Form f = new Form()) { f.ShowDialog(); }it will automatically dispose of form when closed
– Aleksa Ristic
Nov 19 at 0:02
1
Usually a winforms application will have a main form and open subsequent forms, Generally normal applications don't try to minimise the previous form, as the next child form is related to the previous one
– TheGeneral
Nov 19 at 0:03
Secondly, when you are finished with a child form you close it, if its modal, you usually have it in a using statement, control goes back to your previous (non hidden form) and you dont have to create a new form
– TheGeneral
Nov 19 at 0:07
1
Hide() does not hide anything from the machine, only from the user's eyes. Look here for a possible way to get ahead.
– Hans Passant
Nov 19 at 0:50
The thing is: the form is already disposed (and closed) when the user come back from it, but I have a kind of complex menu structure, so it's not only one parent form and a bunch of children. What I'm trying to do is creating a menu, that redirects to a Sign in form that will, if the user and password are correct, show the user a dashboard, that will have a lot of other options. So there are dozens of parent/children relations, that create and need this enormous amount of processing memory.
– Estêvão Rolim
Nov 19 at 3:00
|
show 1 more comment
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
I have been looking for some time on ways to open a second form from another already shown form.
This is some piece of code that works:
frmSecond second = new frmSecond();
this.Hide();
second.ShowDialog();
this.Close();
What it does basically is to Hide() the currently opened form, then it opens another form (the ShowDialog() method). It will only Close() the currently hidden form when the form you have just created is closed.
The problem here is: this way of doing it creates an immense thread of forms. If I need to go from frmSecond to frmThird, it will maintain the first form and the frmSecond being executed in the background, while only showing the frmThird.
Then, as the frmThird is open, if I need to get back to the first form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
And it would create another frmFirst! Then we would have three forms being executed in the background (the first frmFirst, frmSecond, and frmThird).
This method works, but uses an increasingly amount of processing memory, which may be prejudicial for any kind of project.
Is there any alternative or add up to correct this problem?
If anything is unclear, please don't bother in letting me know.
Thank you.
c# .net winforms
I have been looking for some time on ways to open a second form from another already shown form.
This is some piece of code that works:
frmSecond second = new frmSecond();
this.Hide();
second.ShowDialog();
this.Close();
What it does basically is to Hide() the currently opened form, then it opens another form (the ShowDialog() method). It will only Close() the currently hidden form when the form you have just created is closed.
The problem here is: this way of doing it creates an immense thread of forms. If I need to go from frmSecond to frmThird, it will maintain the first form and the frmSecond being executed in the background, while only showing the frmThird.
Then, as the frmThird is open, if I need to get back to the first form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
And it would create another frmFirst! Then we would have three forms being executed in the background (the first frmFirst, frmSecond, and frmThird).
This method works, but uses an increasingly amount of processing memory, which may be prejudicial for any kind of project.
Is there any alternative or add up to correct this problem?
If anything is unclear, please don't bother in letting me know.
Thank you.
c# .net winforms
c# .net winforms
asked Nov 18 at 23:46
Estêvão Rolim
32
32
you could useusing(Form f = new Form()) { f.ShowDialog(); }it will automatically dispose of form when closed
– Aleksa Ristic
Nov 19 at 0:02
1
Usually a winforms application will have a main form and open subsequent forms, Generally normal applications don't try to minimise the previous form, as the next child form is related to the previous one
– TheGeneral
Nov 19 at 0:03
Secondly, when you are finished with a child form you close it, if its modal, you usually have it in a using statement, control goes back to your previous (non hidden form) and you dont have to create a new form
– TheGeneral
Nov 19 at 0:07
1
Hide() does not hide anything from the machine, only from the user's eyes. Look here for a possible way to get ahead.
– Hans Passant
Nov 19 at 0:50
The thing is: the form is already disposed (and closed) when the user come back from it, but I have a kind of complex menu structure, so it's not only one parent form and a bunch of children. What I'm trying to do is creating a menu, that redirects to a Sign in form that will, if the user and password are correct, show the user a dashboard, that will have a lot of other options. So there are dozens of parent/children relations, that create and need this enormous amount of processing memory.
– Estêvão Rolim
Nov 19 at 3:00
|
show 1 more comment
you could useusing(Form f = new Form()) { f.ShowDialog(); }it will automatically dispose of form when closed
– Aleksa Ristic
Nov 19 at 0:02
1
Usually a winforms application will have a main form and open subsequent forms, Generally normal applications don't try to minimise the previous form, as the next child form is related to the previous one
– TheGeneral
Nov 19 at 0:03
Secondly, when you are finished with a child form you close it, if its modal, you usually have it in a using statement, control goes back to your previous (non hidden form) and you dont have to create a new form
– TheGeneral
Nov 19 at 0:07
1
Hide() does not hide anything from the machine, only from the user's eyes. Look here for a possible way to get ahead.
– Hans Passant
Nov 19 at 0:50
The thing is: the form is already disposed (and closed) when the user come back from it, but I have a kind of complex menu structure, so it's not only one parent form and a bunch of children. What I'm trying to do is creating a menu, that redirects to a Sign in form that will, if the user and password are correct, show the user a dashboard, that will have a lot of other options. So there are dozens of parent/children relations, that create and need this enormous amount of processing memory.
– Estêvão Rolim
Nov 19 at 3:00
you could use
using(Form f = new Form()) { f.ShowDialog(); } it will automatically dispose of form when closed– Aleksa Ristic
Nov 19 at 0:02
you could use
using(Form f = new Form()) { f.ShowDialog(); } it will automatically dispose of form when closed– Aleksa Ristic
Nov 19 at 0:02
1
1
Usually a winforms application will have a main form and open subsequent forms, Generally normal applications don't try to minimise the previous form, as the next child form is related to the previous one
– TheGeneral
Nov 19 at 0:03
Usually a winforms application will have a main form and open subsequent forms, Generally normal applications don't try to minimise the previous form, as the next child form is related to the previous one
– TheGeneral
Nov 19 at 0:03
Secondly, when you are finished with a child form you close it, if its modal, you usually have it in a using statement, control goes back to your previous (non hidden form) and you dont have to create a new form
– TheGeneral
Nov 19 at 0:07
Secondly, when you are finished with a child form you close it, if its modal, you usually have it in a using statement, control goes back to your previous (non hidden form) and you dont have to create a new form
– TheGeneral
Nov 19 at 0:07
1
1
Hide() does not hide anything from the machine, only from the user's eyes. Look here for a possible way to get ahead.
– Hans Passant
Nov 19 at 0:50
Hide() does not hide anything from the machine, only from the user's eyes. Look here for a possible way to get ahead.
– Hans Passant
Nov 19 at 0:50
The thing is: the form is already disposed (and closed) when the user come back from it, but I have a kind of complex menu structure, so it's not only one parent form and a bunch of children. What I'm trying to do is creating a menu, that redirects to a Sign in form that will, if the user and password are correct, show the user a dashboard, that will have a lot of other options. So there are dozens of parent/children relations, that create and need this enormous amount of processing memory.
– Estêvão Rolim
Nov 19 at 3:00
The thing is: the form is already disposed (and closed) when the user come back from it, but I have a kind of complex menu structure, so it's not only one parent form and a bunch of children. What I'm trying to do is creating a menu, that redirects to a Sign in form that will, if the user and password are correct, show the user a dashboard, that will have a lot of other options. So there are dozens of parent/children relations, that create and need this enormous amount of processing memory.
– Estêvão Rolim
Nov 19 at 3:00
|
show 1 more comment
3 Answers
3
active
oldest
votes
up vote
2
down vote
accepted
If you want to get access to already created forms try using the static Application.OpenForms property. It contains a list of all of the forms currently open in your application. Documentation is here.
As an example, if you always want to keep frmFirst open and then navigate back to it when you close one of your other forms you can do this:
frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
if (existing != null)
existing.Show();
You would need to remove your this.Close() calls for this to work.
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
add a comment |
up vote
0
down vote
To free the memory you need to dispose the form using the Dispose method when it is no longer needed.
add a comment |
up vote
0
down vote
Seems like you have a desing error here
Then, as the frmThird is open, if I need to get back to the first
form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
This will leave the original created frmFirst in memory, not visible, doing nothing but eating memory.
If you know you want to get back to frmFirst that was created before, why not just do this :
frmFirst.Show();
and save you lots of memory.
You have 2 choices actually
- Hide forms and reactivate them when needed
- Close and dispose forms, and recreate them when needed
What you are doing is creating each form over and over again, without getting rid of the prior created forms. Hence you need lots of memory for hidden forms...
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
add a comment |
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
2
down vote
accepted
If you want to get access to already created forms try using the static Application.OpenForms property. It contains a list of all of the forms currently open in your application. Documentation is here.
As an example, if you always want to keep frmFirst open and then navigate back to it when you close one of your other forms you can do this:
frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
if (existing != null)
existing.Show();
You would need to remove your this.Close() calls for this to work.
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
add a comment |
up vote
2
down vote
accepted
If you want to get access to already created forms try using the static Application.OpenForms property. It contains a list of all of the forms currently open in your application. Documentation is here.
As an example, if you always want to keep frmFirst open and then navigate back to it when you close one of your other forms you can do this:
frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
if (existing != null)
existing.Show();
You would need to remove your this.Close() calls for this to work.
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
add a comment |
up vote
2
down vote
accepted
up vote
2
down vote
accepted
If you want to get access to already created forms try using the static Application.OpenForms property. It contains a list of all of the forms currently open in your application. Documentation is here.
As an example, if you always want to keep frmFirst open and then navigate back to it when you close one of your other forms you can do this:
frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
if (existing != null)
existing.Show();
You would need to remove your this.Close() calls for this to work.
If you want to get access to already created forms try using the static Application.OpenForms property. It contains a list of all of the forms currently open in your application. Documentation is here.
As an example, if you always want to keep frmFirst open and then navigate back to it when you close one of your other forms you can do this:
frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
if (existing != null)
existing.Show();
You would need to remove your this.Close() calls for this to work.
answered Nov 19 at 0:01
Handbag Crab
1,247212
1,247212
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
add a comment |
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
This is awesome, but I'm not sure I'll be able to use it to every form opened in the project. In the main menu, the user will be redirected to a login form, where, if the user and the password is correct, he/she will be redirected to a dashboard, where he/she will have access to a bunch of other options (and forms). So this method is probably more practical if there are forms only with simple constructors, in this project's case, there are dozens of forms with a lot of different arguments. Guess I'll just need a lot of memory anyway, hehe
– Estêvão Rolim
Nov 19 at 3:06
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
Perfect, Thank you very much!
– Estêvão Rolim
Nov 21 at 19:43
add a comment |
up vote
0
down vote
To free the memory you need to dispose the form using the Dispose method when it is no longer needed.
add a comment |
up vote
0
down vote
To free the memory you need to dispose the form using the Dispose method when it is no longer needed.
add a comment |
up vote
0
down vote
up vote
0
down vote
To free the memory you need to dispose the form using the Dispose method when it is no longer needed.
To free the memory you need to dispose the form using the Dispose method when it is no longer needed.
answered Nov 19 at 0:40
Ivan Ičin
3,43642342
3,43642342
add a comment |
add a comment |
up vote
0
down vote
Seems like you have a desing error here
Then, as the frmThird is open, if I need to get back to the first
form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
This will leave the original created frmFirst in memory, not visible, doing nothing but eating memory.
If you know you want to get back to frmFirst that was created before, why not just do this :
frmFirst.Show();
and save you lots of memory.
You have 2 choices actually
- Hide forms and reactivate them when needed
- Close and dispose forms, and recreate them when needed
What you are doing is creating each form over and over again, without getting rid of the prior created forms. Hence you need lots of memory for hidden forms...
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
add a comment |
up vote
0
down vote
Seems like you have a desing error here
Then, as the frmThird is open, if I need to get back to the first
form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
This will leave the original created frmFirst in memory, not visible, doing nothing but eating memory.
If you know you want to get back to frmFirst that was created before, why not just do this :
frmFirst.Show();
and save you lots of memory.
You have 2 choices actually
- Hide forms and reactivate them when needed
- Close and dispose forms, and recreate them when needed
What you are doing is creating each form over and over again, without getting rid of the prior created forms. Hence you need lots of memory for hidden forms...
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
add a comment |
up vote
0
down vote
up vote
0
down vote
Seems like you have a desing error here
Then, as the frmThird is open, if I need to get back to the first
form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
This will leave the original created frmFirst in memory, not visible, doing nothing but eating memory.
If you know you want to get back to frmFirst that was created before, why not just do this :
frmFirst.Show();
and save you lots of memory.
You have 2 choices actually
- Hide forms and reactivate them when needed
- Close and dispose forms, and recreate them when needed
What you are doing is creating each form over and over again, without getting rid of the prior created forms. Hence you need lots of memory for hidden forms...
Seems like you have a desing error here
Then, as the frmThird is open, if I need to get back to the first
form, I would use some code like:
frmFirst first = new frmFirst();
this.Hide();
first.ShowDialog();
this.Close();
This will leave the original created frmFirst in memory, not visible, doing nothing but eating memory.
If you know you want to get back to frmFirst that was created before, why not just do this :
frmFirst.Show();
and save you lots of memory.
You have 2 choices actually
- Hide forms and reactivate them when needed
- Close and dispose forms, and recreate them when needed
What you are doing is creating each form over and over again, without getting rid of the prior created forms. Hence you need lots of memory for hidden forms...
edited Nov 19 at 14:05
answered Nov 19 at 13:57
GuidoG
5,16331743
5,16331743
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
add a comment |
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
Oh, ok! So I'll basically need to use the code Handbag Crab showed up there.
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
this: frmFirst existing = Application.OpenForms.OfType<frmFirst>().FirstOrDefault();
– Estêvão Rolim
Nov 20 at 0:25
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Yes, that is a perfect way to do it. Use the answer from @handbag-crap
– GuidoG
Nov 20 at 7:35
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
Thank you very much, GuidoG
– Estêvão Rolim
Nov 21 at 19:42
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53366610%2fc-sharp-open-a-form-from-another-form-too-much-processing-memory%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
you could use
using(Form f = new Form()) { f.ShowDialog(); }it will automatically dispose of form when closed– Aleksa Ristic
Nov 19 at 0:02
1
Usually a winforms application will have a main form and open subsequent forms, Generally normal applications don't try to minimise the previous form, as the next child form is related to the previous one
– TheGeneral
Nov 19 at 0:03
Secondly, when you are finished with a child form you close it, if its modal, you usually have it in a using statement, control goes back to your previous (non hidden form) and you dont have to create a new form
– TheGeneral
Nov 19 at 0:07
1
Hide() does not hide anything from the machine, only from the user's eyes. Look here for a possible way to get ahead.
– Hans Passant
Nov 19 at 0:50
The thing is: the form is already disposed (and closed) when the user come back from it, but I have a kind of complex menu structure, so it's not only one parent form and a bunch of children. What I'm trying to do is creating a menu, that redirects to a Sign in form that will, if the user and password are correct, show the user a dashboard, that will have a lot of other options. So there are dozens of parent/children relations, that create and need this enormous amount of processing memory.
– Estêvão Rolim
Nov 19 at 3:00