private void Listener_NewUsbEvent(UsbEvent e) { AddDeviceFromEvent(e); ActionEvents(e); Invoke(new Action(() => RefreshUsbDevices())); Invoke(new Action(() => RefreshActions())); }
public static ManagementEventWatcher RegisterRemoveEvent(UsbEvent RemoveEvent) { var removeQuery = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 3"); var removeWatcher = new ManagementEventWatcher(removeQuery); removeWatcher.EventArrived += delegate(object sender, EventArrivedEventArgs e) { // string driveName = e.NewEvent.Properties["DriveName"].Value.ToString(); Action action = delegate { RemoveEvent(); }; Application.Current.Dispatcher.BeginInvoke(action); }; removeWatcher.Start(); return(removeWatcher); }
private void AddDeviceFromEvent(UsbEvent e) { DeviceManager.AddDeviceFromEvent(e); }
private async void ActionEvents(UsbEvent e) { await ActionManagerExecutor.ExecActions(e); }