Daniel,
You did not mention which programming environment you are using, so I will describe the structure in LabVIEW (no matter which language you are using, this should give you the general idea).
1. Configure your DIO port with DIO Port Config.vi.
2. Configure your counter operation (Counter Group Config.vi, etc.).
3. In a while loop, call DIO Port Read.vi.
4. Monitor the bit corresponding to your trigger line. When this bit goes high, stop the while loop.
5. Immediately after the while loop, call Counter Control.vi to arm your counter.
This should be the basic structure of your program. Good luck with your application.
Spencer S.