日期:2014-05-17  浏览次数:20855 次

WebBrowser 中,无法释放内存?

   public partial class Form2 : Form
    {
        public Form2()
        {
            InitializeComponent();
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            webBrowser1.Navigate("http://www.qq.com/");
        }

        protected override void OnClosed(EventArgs e)
        {
            base.OnClosed(e);

            webBrowser1.Dispose();
            webBrowser1 = null;
        }
    }





///////////////////////

   public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            Thread thread = new Thread(new ThreadStart(delegate
            {
                Form2 f = new Form2();

                System.Windows.Forms.Timer timer = new System.Windows.Forms.Timer();
                timer.Interval = 2000;
                timer.Tick += delegate(object o, EventArgs args)
                {
                    timer.Dispose();
                    f.Close();
                };
                timer.Start();
                f.ShowDialog();
                
                Thread.CurrentThrea