12-11-2019 03:14 AM
I am writing an application where I am supplying a set of APIs to interact with my application. I ran my application as async via VI reference, I make an API class, and I intended to write results from my application to this API class. In order to pass the data into my API class, I sent a API class DVR into my application, and modifying the class member in it. However, it does not seem that class member value change as it suppose to if it were by reference ? Where did I do wrong ?
12-11-2019 06:37 AM
@marxious wrote: Where did I do wrong ?
Impossible to really say without code. But my shot in the dark would be you forked the object wire instead of the DVR wire.
12-11-2019 08:15 AM
If you put an object (anything, including a class) in a DVR, (conceptually) a copy is put in the DVR.
So changing the object in the DVR won't change the original object. After you've put it in the DVR, you need to access the object from the DVR (in both 'threads').
(This is exactly what @crossrulz said, but from a different angle.)
12-11-2019 08:45 AM
wiebe@CARYA wrote:
(This is exactly what @crossrulz said, but from a different angle.)
I would say a more complete answer.
12-11-2019 08:46 AM
Also, G# and GOOP is already classes with references. Similar to your idea, but correctly implemented, they use DVRs internally to reference a class' data.
/Y
12-12-2019 02:23 AM
@Yamaeda wrote:
Also, G# and GOOP is already classes with references. Similar to your idea, but correctly implemented, they use DVRs internally to reference a class' data.
/Y
G# and GOOP do it differently, but it isn't wrong to put a normal object in a DVR to get a 'by reference' object. (Not sure if that is what you're saying). I'd avoid it, and try to use other means of distributing objects ((user) events, queue, channel wire). This better fits the 'by value\by wire' model.
Of course if you want everything by reference (the wrong way 🙄, but some people seem to really like it), you're way better of with G#\GOOP\OpenGDS.