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

怎么结束线程
        
//上传照片
private void btnSave_Click(object sender, EventArgs e)
        {
            try
            {
                SysInfo si = new SysInfo();
                this.statusBar1.Text = Status.PicSave;
                threadwcf = new Thread(new ThreadStart(wcfrun));//上传照片线程
                threadtime = new Thread(new ThreadStart(timerun));//计时线程
                threadwcf.IsBackground = true;
                threadwcf.Start();
                threadtime.Start();
            }
            catch
            {
                this.statusBar1.Text = Status.wlanFail;
            }
        }

        private void wcfrun()
        {
            try
            {
                FTPClient d = new FTPClient(FtpInfo.ip, FtpInfo.ml, FtpInfo.yhm, FtpInfo.mm, FtpInfo.dk);
                d.upload(Path.TemporaryPath, "*");
                if (InvokeRequired)
                {
                    Invoke(new NewWcf(enduploadpic));
                }
            }
            catch (Exception ex)
            {
                this.statusBar1.Text = Status.wlanFail;
            }
        }

        //如果超过2秒,则结束上传照片线程
        private void timerun()
        {