J
J
I'm wondering why the form created in the code below stays "alive". I would
have thought that because the form variable is local to the method, that
garbage collection would get rid of it. Makes me wonder if there is a
reference to it somewhere?
// a button on one form is used to call a static method on another form, the
static method creates the form
private void btnNewForm_Click(object sender, System.EventArgs e) {
FormDBSample.ShowForm();
}
//this is the static method that creates the form
public class FormDBSample : System.Windows.Forms.Form
{
....
public static void ShowForm( ){
Cursor.Current = Cursors.WaitCursor;
try{
FormDBSample frmSample = new FormDBSample();
frmSample.Show();
}
finally{
Cursor.Current = Cursors.Default;
}
}
have thought that because the form variable is local to the method, that
garbage collection would get rid of it. Makes me wonder if there is a
reference to it somewhere?
// a button on one form is used to call a static method on another form, the
static method creates the form
private void btnNewForm_Click(object sender, System.EventArgs e) {
FormDBSample.ShowForm();
}
//this is the static method that creates the form
public class FormDBSample : System.Windows.Forms.Form
{
....
public static void ShowForm( ){
Cursor.Current = Cursors.WaitCursor;
try{
FormDBSample frmSample = new FormDBSample();
frmSample.Show();
}
finally{
Cursor.Current = Cursors.Default;
}
}