Avoid Placing Two Event Structures in One Loop

The Event structure handles events in the order they occur. When an event occurs, the Event structure handles the event, the loop reiterates, and the Event structure waits for the next event to occur. If you have two Event structures in a single loop, the loop does not reiterate until both Event structures handle the events for which they were configured. You might hang the user interface if both Event structures do not properly handle the events in the order received.

For example, you might place two Event structures in a single loop and configure the first Event structure to handle a Mouse Down event and configure the second Event structure to handle a Key Down event. The first Event structure receives an event of the type it is configured to handle, such as a Mouse Down event. Then, the second Event structure receives an event of the type it is configured to handle, such as a Key Down event. When both Event structures handle the events, the loop reiterates. If the events continue to alternate, that is Mouse Down, Key Down, Mouse Down, Key Down, and so on, the Event structures handle the events and the loop reiterates.

However, if two Mouse Down events occur sequentially with no intervening Key Down event, the user interface hangs. This is because the Event structure configured to handle the Mouse Down event handles the first Mouse Down event, then the Event structure configured to handle the Key Down event waits. But because a second Mouse Down event occurred, LabVIEW cannot handle the Key Down event until it handles that second Mouse Down event. As a result, LabVIEW cannot reiterate the loop and the user interface hangs.

To avoid hanging the user interface, configure all events you want a VI to handle in a single Event structure or always make sure there is only one Event structure in a loop.