LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Pass .NET reference between callbacks

Solved!
Go to solution

Hello,

 

I have several callback VIs assigned to certain events.

One of these events returns a refnum to an object I need to work with in other callbacks later.

 

I have read I cannot use functional global, becouse the reference gets garbaged, but how can I do this ?

 

I tried to pas it through queue with no luck too.

 

The callback procdure is like this:

 

1. OnMouseEnter - here I get the hoovered object reference

2. OnMouseMove - here I want to work with the reference from 1.

3. OnMouseLeave - here I can free the reference

0 Kudos
Message 1 of 4
(2,636 Views)

Ok so,

 

the only ugly solution I found:

 

snippy.png

 

Is there any better way to recreate the object or to tell labview not to destroy it ?

0 Kudos
Message 2 of 4
(2,628 Views)
Solution
Accepted by topic author Bublina
You can create a System.Stack, push the object on and then pop it back off to get a new reference to the same object. That will work more universally than the approach you showed, which will only work for a handful of types that can be converted to a variant.
Jarrod S.
National Instruments
Message 3 of 4
(2,606 Views)

mscorlib->System.Collections Stack

 

methods push, peek, pop

0 Kudos
Message 4 of 4
(2,593 Views)