private void DetectFaces() { try { if (Timers.currentCount % interval == 0) { if (tcpConnect) { byte[] picturebytes = BitmapToBytes(this.currentFrame); string pic = Convert.ToBase64String(picturebytes) + "@@END@@"; byte[] bt = System.Text.Encoding.Default.GetBytes(pic); //int num = TcpClient.sendData(bt); BackDataHandler handler = new BackDataHandler(tcpClient.sendData); IAsyncResult result = handler.BeginInvoke(bt, new AsyncCallback(CallbackFunc), null); lock (this._sync) {// Thread-1 @@WARNING@@ @@CRITICAL@@ if (backData.Contains("@@CRITICAL@@")) { this.state = "2"; } else if (backData.Contains("@@WARNING@@")) { this.state = "1"; } else { this.state = "0"; } } } else { this.state = "0"; } } } catch { MessageBox.Show("请在配置中设置连接远程服务器!"); } this.currentFrame = null; }
public void CallbackFunc(IAsyncResult result) { BackDataHandler handler = (BackDataHandler)((AsyncResult)result).AsyncDelegate; //this.backData = handler.EndInvoke(result); }