Here's an approach:
As long as you want the same sample rate for both tasks, you can sync them by sharing a sample clock. Designate your AI task as the master (b/c you didn't identify your hardware, some boards wouldn't support DI as a master), run the DI task off the "AISampleClock" signal, and be sure to start the DI task before starting the AI task.
You can further set the AI task to be externally triggered if you also need to be sync'ed to that external repeating signal.
I'm a LabVIEW guy so I can't really help with any of the C# syntax. The trickiest part will be the exact way to specify that the DI task should use the special signal "AISampleClock". It should be findable, I just don't know where to point.
-Kevin P
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).