An event structure executes when events occur. When there is no event, event structures sit idle, consuming no CPU resource, contrary to a while loop, which will execute constantly to poll for events. In addition to executing code based on actual events, it can execute code based on a software event (user event) that is triggered within the software. A user event can also be used to pass data. This recipe demonstrates how to pass data to an event structure.
In this example, we will create a program that passes data between loops based on user events.
Place the
Create User Event
andRegister For Events
functions on the block diagram to create and register an user event. See the following screenshot:The Event Registration Refnum from the
Register for Event
node is fed into the Dynamic Event Terminal of the event structure in the top loop. The User Event Refnum from theCreate User Event
node is fed into the bottom loop to generate a user event...