I have a control with a custom run time menu. My application has a producer-consumer architecture. So the user events are handled in one loop, and all data management in another loop. When I activate the menu of the control, I want to modify it based on the data in the data management loop. For example, if a measurement is ongoing, the menu should have a stop option. Or when the measurement is complete, it should have an "open measurement file" option. But when I send the menu reference from the user event loop to the data management loop to act on it, I get error 1160: illegal menu.
I understand this is by design, so I should handle the modification in the event structure. I was taught to avoid having any functional code inside event structures. It also goes against the design of the producer-consumer architecture. I seems strange to have to send data back from the consumer (data management loop) to the producer (user event loop) in order to modify the menu properly.
What would be the best practice in this case?