请问Form窗体Close后,是否需要显式执行Dispose()方法,否则无法释放资源?
当采用Show()方法时,如何释放资源?w_Form1 wForm1 = new w_Form1();
wForm1.Owner = this;
if (wForm1.ShowDialog() == DialogResult.OK)
{
this.tadLB.Fill(this.dsZL.LB);// 填充数据
}
wForm1.Close();
wForm1.Dispose();
w_Form1 wForm1 = new w_Form1();
wForm1.Owner = this;
wForm1.Show();
//wForm1.Close();
//wForm1.Dispose();
当采用Show()方法时,如何释放资源?w_Form1 wForm1 = new w_Form1();
wForm1.Owner = this;
if (wForm1.ShowDialog() == DialogResult.OK)
{
this.tadLB.Fill(this.dsZL.LB);// 填充数据
}
wForm1.Close();
wForm1.Dispose();
w_Form1 wForm1 = new w_Form1();
wForm1.Owner = this;
wForm1.Show();
//wForm1.Close();
//wForm1.Dispose();
如果不调用则垃圾收集器调用析构函数 只能是否非释放托管资源
this.Close();
this.Dispose();
if (1==1)
{
MessageBox.Show("dd");
}
wForm1.Close(); wForm1.Dispose();
这2行时,内存中还存在wForm1窗口,因为我关闭wForm1窗口的父窗口时,居然还提示我保存wForm1窗口内的数据,wForm1窗口和它的父窗口中的数据是独立无关连的。
让我捏了一把汗。
我也越到过Close之后,再show。还是会保留以前信息的情况