Beispiel #1
0
 protected virtual void Dispose(bool disposing)
 {
     if (Interlocked.Exchange(ref disposed, 1) == 0)
     {
         if (Interlocked.Exchange(ref disposed, 1) == 0)
         {
             //释放非托管资源
             if (ControlCAN.VCI_CloseDevice(objCANDevice.DevType, objCANDevice.DevID) == 0)
             {
                 log.Error("Failed to close CAN device");
             }
         }
     }
 }
Beispiel #2
0
        /// <summary>
        /// 清除接收缓冲区数据
        /// </summary>
        /// <returns></returns>
        public bool ClearBuffer()
        {
            if (Thread.VolatileRead(ref disposed) != 0)
            {
                throw new ObjectDisposedException("CanDevice already disposed");
            }

            if (ControlCAN.VCI_ClearBuffer(objCANDevice.DevType, objCANDevice.DevID, objCANDevice.CANID) == 0)
            {
                log.Error("Failed to clear can.");
                return(false);
            }

            return(true);
        }