09-05-2020 09:28 PM
My code watches for an event where my Toshiba USB stick is unplugged. If the event does not occur within 30 secs, the code times out. However, in the case that there is no disconnection of the USB stick (no event generated), I can't end the program before the timeout period of 30 sec. Is there a way to end the program before the timeout period? Any help is appreciated. Thanks in advance!
Solved! Go to Solution.
09-07-2020 05:24 AM
I don't think you can...
The way to do this (in C#) is to use the Start method, and then use an EventArrivedEventHandler to catch the events asynchronously.
This seems to be one of those situations where it makes perfect sense in C#, but no sense at all in LabVIEW.
I'd try to figure it out in C#, and then use the .NET C# compiler to make a wrapper assembly for LabVIEW This avoid the need for Visual Studio.
09-07-2020 05:38 AM - edited 09-07-2020 05:40 AM
See this example:
The EventArrivedEventWatcher is a delegate, and there's no way to use them in LabVIEW:
WqlEventQuery query =
new WqlEventQuery("__TimerEvent",
"TimerId=\"Timer1\"");
// Initialize an event watcher and
// subscribe to timer events
ManagementEventWatcher watcher =
new ManagementEventWatcher(query);
// Set up a listener for events
watcher.EventArrived +=
new EventArrivedEventHandler(
this.HandleEvent);
watcher.EventArrived is simply not there, and the EventArrivedEventHandler constructor has two (required) parameters in LabVIEW, the object and a pointer.
09-07-2020 01:14 PM
09-08-2020 02:24 AM
@Mode_Locker wrote:
Appreciate the help, wiebe@CARYA!
Solution in LabVIEW here:
I tried the event callback, but didn't get any events. In hindsight, I probably used the normal register for events by mistake.
Next time, please let us know if (and where) you cross post questions... Not doing so is frowned upon.
09-08-2020 02:27 AM
Also, is there any documentation of these queries? They are related to the Classes, but even then the queries seem to be mostly guesswork.