02-01-2010 11:27 AM
So I am sure that this is obvious question, but I cannot find anything similar in the manuals or Google. I have a .Net control on the Front page that generates an event. I use Reg Event Callback to produce a callback vi. This works nicely and the data is delivered from the .Net control to the callback subvi. This is all fine and good, but I need the event to interact with the main VI. Do I have to use global variables for each thing, How do I effect the variables of the main program. My experience is definitely more on the .Net side where this is more obvious.
Thank you
02-01-2010 03:20 PM
Hi there,
Personally (I have not actually seen this done by anyone else). My main vi tends to be a queued state machine architecture. Now because queue references are effectively global. In my .Net even callback vi's i use the Obtain Queue vi to obtain the same queue reference I use in my state machine and then queue my desired state.
Steve
02-01-2010 03:25 PM
Please find demo attached
Steve
02-02-2010 06:38 AM
02-02-2010 06:41 AM
02-02-2010 06:59 AM
There is a reasonably simple way to do this. Create a user event and pass it to the callback as the User Parameter. Register for that same event in your event structure, using the dynamic event registration terminals. In your callback, generate the user event. Now your event structure will, in effect, receive your callback events. See the attached VIs, modified from the ones you posted.
02-02-2010 07:02 AM
08-09-2014 10:16 PM
Hm I tried to make it work but seems it does not... any reason, why?
Please find attached the 2013 VIs...
08-10-2014 09:56 AM - edited 08-10-2014 10:02 AM
@Nelval wrote:
Hm I tried to make it work but seems it does not... any reason, why?
It doesn't work because you took the main VI from my example, and the callback from SteveBale's code. One uses a named queue, the other uses a user event reference passed as a parameter to the callback. Or, put differently, your main VI waits for a user event that never occurs, and your callback puts data into a queue that's never dequeued. Pick one method or the other consistently.
08-11-2014 05:48 AM
@nathand wrote:
@Nelval wrote:
Hm I tried to make it work but seems it does not... any reason, why?
It doesn't work because you took the main VI from my example, and the callback from SteveBale's code. One uses a named queue, the other uses a user event reference passed as a parameter to the callback. Or, put differently, your main VI waits for a user event that never occurs, and your callback puts data into a queue that's never dequeued. Pick one method or the other consistently.
Yup I noticed that.. later, the fact is that you provided your own main and provided the old callback version that's why I was a little bit surprised cause the methods were mismatching, anyway I like the user event generation, a bit more consistent with the Event Structure