Only time for quick comments:
1. Looking at the way you're waiting for a while and then doing a one-time bulk read of samples, you might be better off doing Finite Sampling.
2. Your error was likely caused by waiting too long before hitting the stop button that initiated the Reads, not directly by estimating too low a nominal sample rate. (In an indirect way, the claimed sample rate can affect the auto-sizing of the Continuous Sampling buffer when you leave the input unwired. With Finite Sampling, you aren't allowed to leave the size unwired.
3. Also, when you leave the '# samples to read' input to DAQmx Read unwired, it has a specific meaning. For Continuous Sampling, it means "read all available samples". This explains why you don't always get the same # of samples from your two tasks -- you're asking for "all available" at two slightly different times. The 2nd task to be read might have collected some extras after the 1st task was read. A good workaround would be to read all available from the AI task, take the array size and request that same # samples from the DI task.
When doing Finite Sampling, the meaning would be "read the entire buffer size worth of samples". If you define both buffer sizes to be equal and do Finite Sampling, you'd get the same # of samples from both tasks. Well, as long as you don't time out. That's another Read input you may need to wire.
-Kevin P
ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.