LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to invoke an event and wait till it completes?

Hi,

 

Using a sequence (flat/stacked) placed within an event case, I'd like to know how one could invoke another event case and wait till it completes before proceeding to the next sequence?

The "value signaling" property node only triggers the event to run and continues with the sequence, it does not wait till it finishes.

 

Appreciate all the help/guidance.

 

Regards,

Sable

 

0 Kudos
Message 1 of 3
(3,359 Views)

Sable,

 

You cannot do that as you have described.  LabVIEW uses dataflow.  Your sequence structure is considered a node and will execute to completion before any other node will execute.  Further, the event case is also a node, so no other event case can execute until the current case completes.

 

You will find that most experienced LV programmers avoid the use of sequence structures.  The dataflow paradigm almost always allows a more flexible and powerful approach to solving the problem.

 

Also, it is generally best to not put any code inside an event case which will take much time to execute.  I define "much time" as anything which could take longer than it takes the user to do something which could generate another event, typically 10s of milliseconds is my limit.  I like to use a producer/consumer architecture with information about user activity like button presses passed from the GUIO loop (events) to the processing loop via queues.  Only the enqueue function is inside the event case.  All the work of the program is done in the other loop.

 

There are  design patterns for the producer/consumer architecture which come with LV and many examples in the Forum archives.

 

Lynn 

Message 2 of 3
(3,353 Views)

johnsold wrote:

Sable,

 

You cannot do that as you have described.  LabVIEW uses dataflow.  Your sequence structure is considered a node and will execute to completion before any other node will execute.  Further, the event case is also a node, so no other event case can execute until the current case completes.

 

You will find that most experienced LV programmers avoid the use of sequence structures.  The dataflow paradigm almost always allows a more flexible and powerful approach to solving the problem.

 

Also, it is generally best to not put any code inside an event case which will take much time to execute.  I define "much time" as anything which could take longer than it takes the user to do something which could generate another event, typically 10s of milliseconds is my limit.  I like to use a producer/consumer architecture with information about user activity like button presses passed from the GUIO loop (events) to the processing loop via queues.  Only the enqueue function is inside the event case.  All the work of the program is done in the other loop.

 

There are  design patterns for the producer/consumer architecture which come with LV and many examples in the Forum archives.

 

Lynn 


Ditto that!

 

My "too much time" is a little more loose that Lynn's unless otherwise specified. My default limit is "If the user starts to concider doing a ctrl-alt-del, it is taking too long."

 

Another way to accomplish what you are asking is to have a seperate event structure to hanlde the other event but... you will still have to figure out when it completes. Smiley Mad

 

Jim Krings "Queued Message Handler with Response Notification" design pattern may help out since it provides a mechanism for signalling completion. I have developed a number of custom apps using that code as an inspiration.

 

Have fun!

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 3 of 3
(3,349 Views)