现在的位置: 首页 > 综合 > 正文

C# 窗体退出后关闭线程的代码

2013年05月08日 ⁄ 综合 ⁄ 共 469字 ⁄ 字号 评论关闭

重载OnClosing函数       

protected override void OnClosing(CancelEventArgs e)
        {

            // 这里写关闭窗体要执行的代码
            if (myThread != null)
            {
                if (myThread.IsAlive)
                {
                    // Stop the capturing process
                    myThread.Abort();

                    // Close the pcap device
                    device.Close();
                    textBox1.Text = "视频文件获取完成.............";
                }
            }
            base.OnClosing(e);

        }

抱歉!评论已关闭.