LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to interaction with Main VI from .Net event callback

   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

0 Kudos
Message 1 of 14
(6,285 Views)

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

0 Kudos
Message 2 of 14
(6,272 Views)

Please find demo attached

 

Steve

Message 3 of 14
(6,270 Views)
This is a good solution, but totally inapproriate for the application that I am working on(It is a toolkit for use by beginners).  I will just handle the event in Labview and then set up a query type of system on the main vi.  Seems like a slightly more elegant callback mechanism could be create.
0 Kudos
Message 4 of 14
(6,247 Views)
Yes. It would be nice to be able to register them with the event structure like the dynamic event terminals. Maybe in future releases if we suggest it!
0 Kudos
Message 5 of 14
(6,245 Views)

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.

mousedown callback.PNG

NET callback.PNG

Download All
Message 6 of 14
(6,241 Views)
Awesome 🙂
0 Kudos
Message 7 of 14
(6,233 Views)

Hm I tried to make it work but seems it does not... any reason, why?

 

Please find attached the 2013 VIs...

 

Download All
0 Kudos
Message 8 of 14
(5,319 Views)

@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.

0 Kudos
Message 9 of 14
(5,278 Views)

@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

0 Kudos
Message 10 of 14
(5,251 Views)