public new void Dispose() { addLog("IntermecScanControl Dispose()..."); #if USEWAITLOOP //stop WaitLoop thread _continueWait = false; //signal threads to stop SystemEvent waitEvent = new SystemEvent("EndWaitLoop52", false, false); waitEvent.PulseEvent(); System.Threading.Thread.Sleep(100); int iTry = 0; while (_bWaitLoopRunning && iTry < 5) { System.Threading.Thread.Sleep(300); iTry++; } addLog("IntermecScanControl Dispose(): ending Threads..."); //is the waitThread (waitLoop) still running? if (waitThread != null) { addLog("IntermecScanControl Dispose(): ending event watch thread ..."); waitThread.Abort(); } #endif //dispose BarcodeReader if (bcr != null) { // addLog("IntermecScanControl Dispose(): Calling CancelRead(true)..."); // bcr.CancelRead(true); addLog("IntermecScanControl Dispose(): Disposing BarcodeReader..."); //bcr.ThreadedRead(false); bcr.BarcodeRead -= bcr_BarcodeRead; bcr.Dispose(); bcr = null; addLog("IntermecScanControl Dispose(): BarcodeReader disposed"); } try { addLog("IntermecScanControl Dispose(): enabling HardwareTrigger..."); //replaced this call as ADCComInterface made problems //S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); YetAnotherHelperClass.setHWTrigger(true); YetAnotherHelperClass.setNumberOfGoodReadBeeps(1); } catch (Exception ex) { addLog("IntermecScanControl Dispose(), Exception: enabling HardwareTrigger: " + ex.Message); } addLog("IntermecScanControl Dispose(): restoring Scan Button Key..."); ITCTools.KeyBoard.restoreKey(); addLog("...IntermecScanControl Dispose(): end."); //base.Dispose(); do not use!! }
public new void Dispose() { addLog("IntermecScanControl Dispose()..."); //dispose BarcodeReader if (bcr != null) { // addLog("IntermecScanControl Dispose(): Calling CancelRead(true)..."); // bcr.CancelRead(true); addLog("IntermecScanControl Dispose(): Disposing BarcodeReader..."); bcr.BarcodeRead -= bcr_BarcodeRead; bcr.BarcodeReadCanceled -= bcr_BarcodeReadCanceled; bcr.BarcodeReadError -= bcr_BarcodeReadError; try { bcr.NoBarcodeRead -= bcr_NoBarcodeRead; bcr.EnableNoBarcodeReadEvent = false; } catch (Exception) { addLog("Unable to unset bcr.EnableNoBarcodeReadEvent. Old DLL?"); } bcr.ThreadedRead(false); bcr.Dispose(); bcr = null; addLog("IntermecScanControl Dispose(): BarcodeReader disposed"); } try { addLog("IntermecScanControl Dispose(): enabling HardwareTrigger..."); //replaced this call as ADCComInterface made problems //S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); YetAnotherHelperClass.setHWTrigger(true); YetAnotherHelperClass.setNumberOfGoodReadBeeps(1); } catch (Exception ex) { addLog("IntermecScanControl Dispose(), Exception: enabling HardwareTrigger: " + ex.Message); } addLog("IntermecScanControl Dispose(): restoring Scan Button Key..."); ITCTools.KeyBoard.restoreKey(); addLog("...IntermecScanControl Dispose(): end."); //base.Dispose(); do not use!! }
public IntermecBarcodescanControl5() { InitializeComponent(); try { addLog("IntermecBarcodescanControl5: setHWTrigger(true)..."); //enable HW trigger, a workaround as HW trigger is sometimes disabled on BarcodeReader.Dispose() //if (!S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true)) //{ // addLog("IntermecBarcodescanControl5: setHWTrigger(true)...FAILED. Trying again"); // Thread.Sleep(50); // S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); //try again //} //replaced above code with the following, there were problems with load/unload the ADCComInterface inside S9CConfig YetAnotherHelperClass.setHWTrigger(true); //change number of good read beeps to zero YetAnotherHelperClass.setNumberOfGoodReadBeeps(0); addLog("IntermecBarcodescanControl5: mapKey()..."); //we use the standard scan key assignement: addLog("IntermecBarcodescanControl5: restoreScanKeyDefault()..."); ITCTools.KeyBoard.restoreScanKeyDefault(); } catch (Exception ex) { addLog("Exception in IntermecBarcodescanControl5: setHWTrigger(true)..." + ex.Message); } try { //Cannot use Keydown etc within a usercontrol, we will not get the events!!!!! ITCTools.KeyBoard.createMultiKey2Events(); #if USEWAITLOOP addLog("IntermecBarcodescanControl2: starting named event watch thread..."); waitThread = new System.Threading.Thread(waitLoop); //waitThread.Priority = ThreadPriority.Lowest; //does not help waitThread.Start(); #endif addLog("IntermecBarcodescanControl5: new BarcodeReader()..."); //create a new BarcodeReader instance bcr = new BarcodeReader(this, "default");// (); addLog("IntermecBarcodescanControl5: BarcodeReader adding event handlers..."); bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead); bcr.BarcodeReadCanceled += new BarcodeReadCancelEventHandler(bcr_BarcodeReadCanceled); bcr.BarcodeReadError += new BarcodeReadErrorEventHandler(bcr_BarcodeReadError); addLog("IntermecBarcodescanControl5: enabling Scanner..."); bcr.ScannerEnable = true; addLog("IntermecBarcodescanControl5: ScannerOn=false..."); bcr.ScannerOn = false; addLog("Enabling event driver scanning"); bcr.ThreadedRead(true); } catch (BarcodeReaderException ex) { bcr = null; System.Diagnostics.Debug.WriteLine("BarcodeReaderException in IntermecScanControl(): " + ex.Message); } catch (Exception ex) { bcr = null; System.Diagnostics.Debug.WriteLine("Exception in IntermecScanControl(): " + ex.Message); } if (bcr == null) { addLog("IntermecBarcodescanControl5: BarcodeReader init FAILED"); throw new System.IO.FileNotFoundException("Intermec.Datacollection.dll or ITCScan.DLL missing"); } #if TESTMODE //testcodes = new string[8]; testCodeCount = testcodes.Length; testCodePos = 0; #endif }
public IntermecBarcodescanControl5() { InitializeComponent(); try { #if RANDOMBADSCANS rc = new RandomClass(0.3); #endif addLog("IntermecBarcodescanControl5: setHWTrigger(true)..."); //enable HW trigger, a workaround as HW trigger is sometimes disabled on BarcodeReader.Dispose() //if (!S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true)) //{ // addLog("IntermecBarcodescanControl5: setHWTrigger(true)...FAILED. Trying again"); // Thread.Sleep(50); // S9CconfigClass.S9Cconfig.HWTrigger.setHWTrigger(true); //try again //} //replaced above code with the following, there were problems with load/unload the ADCComInterface inside S9CConfig YetAnotherHelperClass.setHWTrigger(true); //change number of good read beeps to zero YetAnotherHelperClass.setNumberOfGoodReadBeeps(0); //as with new NullBarcodeRead events, we do not need to remap to StateLeftScan2 ! //addLog("IntermecBarcodescanControl5: mapKey()..."); //ITCTools.KeyBoard.mapKey(); //we use the standard scan key assignement: addLog("IntermecBarcodescanControl5: restoreScanKeyDefault()..."); ITCTools.KeyBoard.restoreScanKeyDefault(); addLog("IntermecBarcodescanControl5: mapAllSide2SCAN_Event1() (all side buttons to scan event 1)..."); ITCTools.KeyBoard.mapAllSide2SCAN_Event1(); } catch (Exception ex) { addLog("Exception in IntermecBarcodescanControl5: setHWTrigger(true)..." + ex.Message); } try { //Cannot use Keydown etc within a usercontrol, we will not get the events!!!!! //ITCTools.KeyBoard.createMultiKey2Events(); addLog("IntermecBarcodescanControl5: new BarcodeReader()..."); //create a new BarcodeReader instance bcr = new BarcodeReader(this, "default");// (); try { #if NoBarcodeRead //modded code for new NoBarcodeRead feature bcr.NoBarcodeRead += new NoBarcodeReadEventHandler(bcr_NoBarcodeRead); bcr.EnableNoBarcodeReadEvent = true; addLog("Setting bcr.EnableNoBarcodeReadEvent. OK?"); #endif } catch (Exception) { addLog("Unable to set bcr.EnableNoBarcodeReadEvent. Old DLL?"); } addLog("IntermecBarcodescanControl5: BarcodeReader adding event handlers..."); bcr.BarcodeRead += new BarcodeReadEventHandler(bcr_BarcodeRead); bcr.BarcodeReadCanceled += new BarcodeReadCancelEventHandler(bcr_BarcodeReadCanceled); bcr.BarcodeReadError += new BarcodeReadErrorEventHandler(bcr_BarcodeReadError); addLog("IntermecBarcodescanControl5: enabling Scanner..."); bcr.ScannerEnable = true; addLog("IntermecBarcodescanControl5: ScannerOn=false..."); bcr.ScannerOn = false; addLog("Enabling event driver scanning"); bcr.ThreadedRead(true); } catch (BarcodeReaderException ex) { bcr = null; System.Diagnostics.Debug.WriteLine("BarcodeReaderException in IntermecScanControl(): " + ex.Message); } catch (Exception ex) { bcr = null; System.Diagnostics.Debug.WriteLine("Exception in IntermecScanControl(): " + ex.Message); } if (bcr == null) { addLog("IntermecBarcodescanControl5: BarcodeReader init FAILED"); throw new System.IO.FileNotFoundException("Intermec.Datacollection.dll or ITCScan.DLL missing"); } #if TESTMODE //testcodes = new string[8]; testCodeCount = testcodes.Length; testCodePos = 0; #endif }