日期:2014-05-18 浏览次数:20888 次
private void Switch_Click(object sender, EventArgs e) { BackgroundWorker bgWorker = new BackgroundWorker(); bgWorker.DoWork += new DoWorkEventHandler((sender1, e1) => { try { comm.DataReceived -= comm_DataReceived;//取消注册串口接收事件 comm.Close();//关闭串口 } finally { } }); bgWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler((sender2, e2) => { Canshu_Class.flag = true; this.Close();//关闭当前界面 DanMian d1 = new DanMian(); d1.ShowDialog();//打开新界面 }); bgWorker.RunWorkerAsync(); }