Example #1
0
        /// <summary>
        /// Close the scanner device
        /// </summary>
        public void Close()
        {
            if (reader == null)
            {
                scannerStatus = ScannerStatus.Closed;
                return;
            }

            StopRead();

            reader.Actions.Disable();
            reader.Dispose();
            reader = null;
            readerData.Dispose();
            readerData = null;

            scannerStatus = ScannerStatus.Closed;
        }
        /// <summary>
        /// Stop reading and disable/close the reader.
        /// </summary>
        public void TermReader()
        {
            // If we have a reader
            if (myReader != null)
            {
                try
                {
                    // stop all the notifications.
                    StopRead();

                    //Detach all the notification handler if the user has not done it already.
                    DetachReadNotify();
                    DetachStatusNotify();

                    // Disable the reader.
                    myReader.Actions.Disable();

                    // Free it up.
                    myReader.Dispose();

                    // Make the reference null.
                    myReader = null;
                }

                catch {}
            }

            // After disposing the reader, dispose the reader data.
            if (myReaderData != null)
            {
                try
                {
                    // Free it up.
                    myReaderData.Dispose();

                    // Make the reference null.
                    myReaderData = null;
                }

                catch {}
            }
        }
        /// <summary>
        /// Terminates the Symbol scanner.
        /// </summary>
        public override void Terminate()
        {
            // If we have a scanner
            if (symbolReader != null)
            {
                // Disable the scanner
                symbolReader.Actions.Disable();

                // Free it up
                symbolReader.Dispose();

                // Indicate we no longer have one
                symbolReader = null;
            }

            // If we have a scanner data object
            if (symbolReaderData != null)
            {
                // Free it up
                symbolReaderData.Dispose();

                // Indicate we no longer have one
                symbolReaderData = null;
            }
            if (xSymKeyPad != null)
            {
                xSymKeyPad.AlphaNotify    -= ALPNotify;
                xSymKeyPad.KeyStateNotify -= Sym48_KeyStateNotify;
                xSymKeyPad.Dispose();
            }
            if (xWLan != null)
            {
                xWLan.Dispose();
            }
            //if (xRadio != null)
            //    xRadio.Dispose();
        }