void WaitingPCIE(object LockWatingThread) { while (true) { pCH368 = CH368.CH367mOpenDevice(CH368Index, TRUE, TRUE, 0x00); if (pCH368 != (IntPtr)(-1)) { this.Invoke((EventHandler)(delegate { InitPCIE(); })); return; } Thread.Sleep(1000); lock (LockWatingThread) { wp.SetProcessBarPerformStep(); if (wp.HasBeenCancelled()) { this.Invoke((EventHandler)(delegate { this.Close(); })); return; } } } }
private void startTimer_Tick(object sender, EventArgs e) { startTimer.Enabled = false; wp = new WaitingProc(); WaitingProcFunc wpf1 = new WaitingProcFunc(WaitingSQL); wp.Execute(wpf1, "等待数据库启动", WaitingType.None, ""); pCH368 = CH368.CH367mOpenDevice(CH368Index, TRUE, TRUE, 0x00); if (pCH368 == (IntPtr)(-1)) { wp = new WaitingProc(); WaitingProcFunc wpf = new WaitingProcFunc(WaitingPCIE); wp.Execute(wpf, "等待连接采集卡", WaitingType.With_ConfirmCancel, "未连接到采集卡,取消将退出软件,是否取消?"); } else { this.Invoke((EventHandler)(delegate { this.Enabled = true; })); InitPCIE(); } }