//======================================================================================== // Methods //======================================================================================== /// <summary> /// Internally handle state changes and notify listeners. /// </summary> /// <param name="e"></param> private void DoStateChanged(UsbStateChangedEventArgs e) { if (handler != null) { // we can only interrogate drives that are added... // cannot see something that is no longer there! if ((e.State == UsbStateChange.Added)) { // the following Begin/End invokes looks strange but are required // to resolve a "DisconnectedContext was detected" exception which // occurs when the current thread terminates before the WMI queries // can complete. I'm not exactly sure why that would happen... } handler(e); } }
private void USBDeviceStateChanged(UsbStateChangedEventArgs e) { timer1.Enabled = true; }