In the following example, each task runs independently and at different rates from the other tasks.
Data passes between tasks using local variables.
Note: This examples uses local variables for presentation purposes only. Using local variables might result in lost or duplicated data.
Note the following issues in this approach:
- The tasks no longer run in a particular order.
- Depending on the rate the Acquire Data task runs compared to the Analyze Data task, some data might not be analyzed and some data might be analyzed twice.
- You can write the tasks in such a way as to allow the Acquire Data task to run quickly and always acquire all data, while the Analyze Data and Show Data tasks only occur frequently enough to show the user what is happening.
- Each task can run in its own thread.
This first two issues seem like disadvantages, but you can take advantage of the issues. For example, suppose that the Acquire Data task also saves the acquired data to disk. This saved copy of the acquired data has all the data if you need a complete log of the data later. The other tasks can then run slower, skipping some data, and display only the latest data while analyzing the data.
Another advantage of this approach is that it allows prioritization. With some additional work, you can configure the three tasks so the Acquire Data task gets priority of execution over analysis and presentation. That way, slower computers can acquire and save data without getting errors.