Beispiel #1
0
        /// <summary>
        /// The close method closes the CANUSB device.
        /// </summary>
        /// <returns>CloseResult.OK on success, otherwise CloseResult.CloseError.</returns>
        override public CloseResult close()
        {
            Console.WriteLine("Close called in CANUSBDevice");
            if (m_readThread != null)
            {
                if (m_readThread.ThreadState != ThreadState.Stopped && m_readThread.ThreadState != ThreadState.StopRequested)
                {
                    lock (m_synchObject)
                    {
                        m_endThread = true;
                    }
                    // m_readThread.Abort();
                }
            }
            int res = EASYSYNC.canusb_Close(m_deviceHandle);

            m_deviceHandle = 0;
            if (EASYSYNC.ERROR_CANUSB_OK == res)
            {
                return(CloseResult.OK);
            }
            else
            {
                return(CloseResult.CloseError);
            }
        }
        /// <summary>
        /// The close method closes the CANUSB device.
        /// </summary>
        /// <returns>CloseResult.OK on success, otherwise CloseResult.CloseError.</returns>
        override public CloseResult close()
        {
            int res = 0;

            try
            {
                res = EASYSYNC.canusb_Close(m_deviceHandle);
            }
            catch (DllNotFoundException e)
            {
                return(CloseResult.CloseError);
            }

            m_deviceHandle = 0;
            if (EASYSYNC.ERROR_CANUSB_OK == res)
            {
                return(CloseResult.OK);
            }
            else
            {
                return(CloseResult.CloseError);
            }
        }