Jump to content

Reference Loss


pierre

Recommended Posts

Hello,

I am actualy designing a program using a Model-View-Presenter Template.

Views and presenters are contretized by dynamic lauched Vis.

Models are shared between Presenters using LV References.

Main models are instantiated by the main presenter. Others models, that might belong to main models can be instantiated by sub presenter within sub presenter thread.

Using execution-trace I noticed that all references created in sub presenter thread are destroyed when thread stops.

That is very annoying because the aim of sub presenters is to modifiy and eventualy create sub models. And if sub models can not be reused after sub presenter is destroyed, my design pattern will never work.

Does anybody ever met this situation?

Is there any way to ask labview runtime to keep valid references created in dynamic launched VI when this one stops?

thanx for answer.

Pierre

Edited by pierre
Link to comment

There are a couple of things that come to mind. One is to transfer ownership of the ref from the VI that launches a dynamic VI in a new thread to the dynamic VI. Then it doesn't matter if the caller goes out of scope. This happens with the arguments to the Run method from the invoke node (LV 2010 and earlier) - LV 2011 has the new Async VI call primitive and it can do the same thing by setting the arguments to the VI Ref open method. There's a recent thread here on LAVA that has much info about that (http://lavag.org/top...nchronous-call/). The other method that might work is to create a functional global that is a "reference pool". Call this FGV by something (like the main panel) that never gets unloaded and store create all of your refs in there. The FGV should never go out of scope and the refs should not be destroyed. In this case, do not transfer ownership of the ref to the called VI. This might work for you.

Mark

Link to comment

There are a couple of things that come to mind. One is to transfer ownership of the ref from the VI that launches a dynamic VI in a new thread to the dynamic VI. Then it doesn't matter if the caller goes out of scope. This happens with the arguments to the Run method from the invoke node (LV 2010 and earlier) - LV 2011 has the new Async VI call primitive and it can do the same thing by setting the arguments to the VI Ref open method. There's a recent thread here on LAVA that has much info about that (http://lavag.org/top...nchronous-call/). The other method that might work is to create a functional global that is a "reference pool". Call this FGV by something (like the main panel) that never gets unloaded and store create all of your refs in there. The FGV should never go out of scope and the refs should not be destroyed. In this case, do not transfer ownership of the ref to the called VI. This might work for you.

Mark

I first tried Global Functionnal with no success. Actualy, even if creation is made in global fonctionnal, global fonctionnal is called in Dynamic Vi context, so Reference seems to belong to Dynamic Vi context...

The solution I have choosen is post on NI forum : http://forums.ni.com...1698122#M601558

Thanx for answers

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.