09-08-2010 05:01 AM
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..
09-08-2010 06:00 AM
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.
09-08-2010 07:14 AM
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.
09-08-2010 09:23 AM
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.
09-08-2010 09:34 AM
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.