C
Crile Carvey
I have created a ManagementEventWatcher and a corresponding
EventArrivedEventHandler. The basics work fine - when a USB device is
inserted or removed, the EventArrivedEventHandler fires successfully.
However, any references to UI objects on the form fail without any error
messages. When walking through the code in the debugger, the lines are
seemingly ignored.
Any help appreciated.
Crile
Please refer to the following snippet:
q = new WqlEventQuery();
q.EventClassName = "__InstanceCreationEvent";
q.WithinInterval = new TimeSpan(0, 0, 3);
q.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
w = new ManagementEventWatcher(scope, q);
w.EventArrived += new EventArrivedEventHandler( USBInserted);
w.Start();//run the watcher
public void USBInserted(object sender, EventArgs e) {
// Debugger gets to here but following line is apparently ignored
this.listBox1.Items.Add("Inserted: " + DateTime.Now.ToString());
}
EventArrivedEventHandler. The basics work fine - when a USB device is
inserted or removed, the EventArrivedEventHandler fires successfully.
However, any references to UI objects on the form fail without any error
messages. When walking through the code in the debugger, the lines are
seemingly ignored.
Any help appreciated.
Crile
Please refer to the following snippet:
q = new WqlEventQuery();
q.EventClassName = "__InstanceCreationEvent";
q.WithinInterval = new TimeSpan(0, 0, 3);
q.Condition = @"TargetInstance ISA 'Win32_USBControllerdevice'";
w = new ManagementEventWatcher(scope, q);
w.EventArrived += new EventArrivedEventHandler( USBInserted);
w.Start();//run the watcher
public void USBInserted(object sender, EventArgs e) {
// Debugger gets to here but following line is apparently ignored
this.listBox1.Items.Add("Inserted: " + DateTime.Now.ToString());
}