LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Noob Question - Buttons seem to hang when being in an event loop

jup 🙂

exactely when I did that, I found out what the error was 🙂


is there a reason not to use local variables ? I am quite new to this 😞
0 Kudos
Message 11 of 15
(822 Views)
Using local variables can be convenient for building a VI quickly or reducing the amount of wiring and re-wiring, but each use of a local variable generates a copy of the data in memory (RAM), which can become a significant issue when your program and/or the data stored in the variable grows.

There is more information on LabVIEW and memory management in a white paper that you can find by using the LabVIEW menu item "Help>>Search the LabVIEW Bookshelf. ..."

Message Edited by Isaak on 09-01-2005 12:17 PM

0 Kudos
Message 12 of 15
(818 Views)

There is nothing wrong using local variables if they are really needed, e.g. for the UI code. They should not be used for pure computations (e.g.  to "avoid" wires). In your case, they are definitely not needed.

Local variables have several drawbacks.

  1. They break dataflow and thus can cause race conditions an make the code hard to read and debug.
  2. They lower performance because they cause a data copy in memory and require a switch to the UI thread.

For more details, you might want to look at my old post here and other post in that thread. 🙂

0 Kudos
Message 13 of 15
(814 Views)

Just a quick note on event structures: keep the code running inside each event to a minimum otherwise you will see a hang effect.  The event structure is for GUI responsiveness to avoid polling so running any long routines inside of an event defeats the purpose of the structure in the first place.  Yes the producer/consumer design pattern solves this so you can handle GUI events quickly in a gui event loop and handle DAQ and processing an their own loop, with message passing to share information.  Just put a long wait inside an event and see what happens to the program.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 14 of 15
(807 Views)

When I said keep the events inside of the event structure short, I would suggest 250ms max, I find anything over .5sec to appear unresponsive but maybe I am impactions.

Paul

Paul Falkenstein
Coleman Technologies Inc.
CLA, CPI, AIA-Vision
Labview 4.0- 2013, RT, Vision, FPGA
0 Kudos
Message 15 of 15
(807 Views)