My application has two distinct forms;
- the main application form,
- another one showing warnings, info, error, etc. (only when needed).
In form 1 (the application's main form), second form is called in various lines, as below;
FormMain:
...
if (sth_goes_wrong) {
this.formWarn = new FormWarn("explanatory message...");
this.formWarn.Dispose(); // <- this is the line in question
}
...
FormWarn:
internal class FormWarn : Form {
...
public FormWarn(String msg) {
this.SetupStuff();
this.btnOk.Click += FormWarn_BtnOkClick;
...
this.ShowDialog();
}
private FormWarn_BtnOkClick(Object sender, EventArgs e) {
...
this.Close();
}
...
}
The warning form in shown as "dialog" and the user, after reading the message, is supposed to press a button (btnOk) which sends the program flow to a line with Close()
method.
My question is; does that Close()
method (in the FormWarn
class) take care of freeing resources or do I need to use a Dispose()
method after returning back to the main form?