There are several possibilities. The best choice will depend on your app. Here is a partial list of methods:
1.
Global Variables: Simple and straightforward, but generally frowned upon as bad style. Also, there are issues with race conditions and performance hits (especially with large data structures)
2.
Functional Globals: aka "LabVIEW-2 style globals"
Still pretty easy to implement (especially after you've made your first 2 or 3). Allows some encapsulation of data, with accessor and manipulator functions. Generally regarded as a Very Good Thing. However, no guarantee that "consumer" outside the loop responds to every value written by "producer" inside the loop. On the other hand, easily supports designs with many parallel consumers.
3.
Local Variables, Property Nodes, Control References: Local variables not the best solution, similar to Globals. Property Nodes and Control References are
not the preferred means to communicate data values.
4.
Notifiers: Can set up interrupt-like behavior. "Producer" inside the loop puts (changed) value into notifer and "throws" it. "Consumer" outside the loop is not burning CPU time polling, but merely sleeping while waiting on notification. When a notification is "caught", the data value can be extracted. I'd put them in the Very Good Thing department.
5.
Queues: Write to queue inside the loop (possibly only when the value changes). Elsewhere you query the queue to retrieve data. Buffers values so that "consumer" outside the loop can see every value change, in order. Also generally considered a Very Good Thing, but best used with a single consumer.
6.
Combos: Combine the Notifier with either the Functional Global or the Queue. The producer puts a changed value into the F.G. or the Q., then throws a notification. The consumer catches the notification and reads the value out from the F.G. or Q. This scheme is especially nice if your F.G. holds a complex and large data structure, and each of several consumers can simultaneously catch the notification and extract the particular part they care about.
Note: with these schemes, you'd probably use Occurrences rather than actual Notifiers. They operate similarly, except Occurrences don't pass data.
-Kevin P.
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.