Exemple #1
0
        public override bool Recover()
        {
            try
            {
                if (loopDevice != null)
                {
                    loopDevice.Dispose();
                    loopDevice = null;
                }

                if (usbDevices != null)
                {
                    usbDevices.DeviceRemoved  -= usbDevices_DeviceRemoved;
                    usbDevices.DeviceAttached -= usbDevices_DeviceAttached;
                    usbDevices.Dispose();
                    usbDevices = null;
                }
            }
            catch (System.Exception ex)
            {
            }


            inEndpoint  = null;
            outEndpoint = null;

            usbDevices = new USBDeviceList(CyConst.DEVICES_CYUSB);
            usbDevices.DeviceRemoved  += new EventHandler(usbDevices_DeviceRemoved);
            usbDevices.DeviceAttached += new EventHandler(usbDevices_DeviceAttached);
            return(intDevice());
        }
Exemple #2
0
 } // end private void mUSBDevList_Attached(Object sender, EventArgs e)
 /// <summary>
 /// detected the usb is removing
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void mUSBDevList_Removed(Object sender, EventArgs e)
 {
     mCyUSBDev.Dispose();
     mUSBDevList.Dispose();
     mUSBDevList.DeviceAttached -= mUSBDevList_Attached;
     mUSBDevList.DeviceRemoved -= mUSBDevList_Removed;
 } // end private void mUSBDevList_Removed(Object sender, EventArgs e)