If this event structure is in the same loop as your data acquisition, the aquisition will grind to a halt because it will wait indeifinitely for each event. if you use a timeout in the event structure to avoid this, you have effectively returned to polling.
Why do you feel you need to flush the VISA I/O buffer? Just a precaution? If this "solves" a problem, the it's likely you are not communicating correctly with the unit. Which, of course, could be the reason behind the timeout.
Depending on what you mean by "high sample rate", this architecture might not work for you at all, as it appears that data acqusition and processing are happening in the same loop.
This code, IMHO, seems very fragile and can break down in so many ways. That's why I recommend starting from scratch, using an appropriate design pattern so we can help you build a robust solution instead of fixing one thing only to break or expose another (worse yet, to leave something unexposed and lurking). "Winging it" hardly ever produces good code.
Bill
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the
CLAD Nugget.