Reuse of null class



查看以下代码

namespace WindowsFormsApplication1
{
public partial class myprogram : Form
{
public myprogram()
{            
InitializeComponent();
}
WebKitBrowser wb1 = new WebKitBrowser();

private void timer1_Tick(object sender, EventArgs e)
{
timer1.Enabled = false;
wb1.Navigate("site.com");
timer2.Enabled = true;
}
private void timer2_Tick(object sender, EventArgs e)
{
timer2.Enabled = false;
wb1=null;    
timer1.Enabled = true;
}      
}
}

要每次清空RAM,wb1必须为null。但随后它变为null,不再命中并表示它已经为null。那么,如何在timer2中获取null,然后在timer1中导航呢?

wb1 = new WebKitBrowser();添加到timer1_Tick

相关内容

最新更新