void dcdEvent_Scanned(object sender, DcdEventArgs e) { string id = hDcd.ReadString(e.RequestID); id = id.Substring(0, id.Length - 1); if (isBusy) { return; } this.Invoke(delegateIdScanned, new object[] { id }); }
/// <summary> /// Event that fires when a PSC scanner has performed a scan. /// </summary> private void dcdEvent_Scanned(object sender, DcdEventArgs e) { nCodeID = CodeId.NoData; sBarCode = string.Empty; // Obtain the string and code id. try { sBarCode = hPSC.ReadString(e.RequestID, ref nCodeID); } catch (Exception) { //MessageBox.Show("Error reading string!"); } OnBarcodeScan(new BarcodeScannerEventArgs((BCId)nCodeID, sBarCode)); return; }
/// <summary> /// This method will be called when the DcdEvent is invoked. /// </summary> private void dcdEvent_Scanned(object sender, DcdEventArgs e) { if (App.ignoreScan || App.ScanHandler == null) { return; } CodeId cID = CodeId.NoData; string dcdData = string.Empty; // Obtain the string and code id. try { dcdData = hDcd.ReadString(e.RequestID, ref cID); lock (scanQueue.SyncRoot) { scanQueue.Enqueue(new ScanData(cID.ToString(), dcdData)); } } catch (Exception ex) { Log.Exception(ex); } }
/// <summary> /// Другой поток: обработка события "Код сканирован" и переход к потоку данного окна /// </summary> void DcdEvent_Scanned(object sender, DcdEventArgs e) { try { //DcdEvent.Scanned -= DcdScannedDelegate; if (DcdHandle.GetCodeId(e.RequestID) == CodeId.NoData) { throw new Exception("Данные не считаны"); } string scanned = DcdHandle.ReadString(e.RequestID); scanned = scanned.Substring(0, scanned.Length - 1); //this.Invoke(Delegate, new object[] { scanned }); InterpretScannedID(scanned); //DcdEvent.Scanned += DcdScannedDelegate; } catch (Exception ex) { MessageBox.Show("Ошибка: " + ex.Message, "Сканирование штрих-кода", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1); return; } }