public void TestThread() { try { f = new Func(); f.SetDMPath(PicPath); Thread.Sleep(500); int pid = 0, handle = 0; if (this.txtPID.Text.Trim() != "") { pid = int.Parse(txtPID.Text.Trim()); } if (this.txtHandle.Text.Trim() != "") { handle = int.Parse(txtHandle.Text.Trim()); } f.BindDM(ClassName, pid, handle); f.Test(); f.UnBindDM(); this.Invoke(DelegateSetControl, new object[] { gbSetting, true }); this.Invoke(DelegateSetControl, new object[] { gbStart, true }); } catch (Exception ex) { this.Invoke(delegateShowMsg, new object[] { ex.Message }); if (f != null) { f.UnBindDM(); this.Invoke(DelegateSetControl, new object[] { gbSetting, true }); this.Invoke(DelegateSetControl, new object[] { gbStart, true }); } } }