LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

wait on event in DLL

I've been experimenting with calling external code from labview, successfully used PostLVUserEvent to generate an event. Now I am wondering what is the best method for waiting on a labview event inside the DLL. I've spotted that using the Occur() function exported by labview its possible to set an occurrence, but is it possible to wait on one as well - inside the dll? Currently I'm using a window's event for this, by passing the handle to labview and having a dll function that fires the event. Wondering if this is the best method to use, or the only one..

0 Kudos
Message 1 of 5
(3,017 Views)

Why wait inside the DLL at all?

 

Surely just calling a DLL function from the your LV code when you need to effectively achieves your goal? No occurences or anything else needed.

0 Kudos
Message 2 of 5
(3,003 Views)

Not knowing what you are attempting to do I will point out that when you enter a dll that thread waits for the dll to complete. If the dll isn't marked as "run in any thread" and is instead running in the UI thread your program, at least from the point of view of a user, will have locked up. As the previous poster pointed out, could you restructure your code so that whatever function is to be accomplished within the dll can just be called from LabVIEW, when LabVIEW responds to the event? Are you trying to respond to a Windows event? It isn't entirely clear.

Putnam
Certified LabVIEW Developer

Senior Test Engineer North Shore Technology, Inc.
Currently using LV 2012-LabVIEW 2018, RT8.5


LabVIEW Champion



0 Kudos
Message 3 of 5
(2,990 Views)

As far as I know the only way is setting occurrence / generate event from DLL. There are no functions for waiting event available (at least official available).

So, I'll suggest to use standard WinAPI (WaitForSingleObject / SetEvent / etc). This will require additional DLL call for event generation.

Or just split your DLL function into two parts (before wait / after wait) and use standard LabVIEW functions between.

 

Andrey.

 

0 Kudos
Message 4 of 5
(2,975 Views)

hey thanx for the info, my application is actually calling labview from lua.. I know LuaVIEW does it, but I wanted to see if i could do something similar. Anyway it looks like I'll just continue using the winapi, its working, just wanted to know if there is some other way.

0 Kudos
Message 5 of 5
(2,971 Views)