This example VI contains a queue that stores events generated by an Event Structure in a Producer Loop. Rather than having the code for each event run in the Event Structure, the Event Structure quickly passes what event occurred out and enqueues that information. That information is than dequeued in a Consumer Loop where the code for each event actually runs. When the code for the first event finishes in the Consumer Loop, the next event in the queue’s code will run next… While the Producer Loop is enqueueing events and the Consumer Loop is dequeueing elements and running code, the queue can be read and manipulated anywhere on the block diagram. In this example VI, there is a Monitor Loop that monitors # of elements in queue and queue elements. There is also a mechanism for clearing the queue.
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.