In LabVIEW
Find Examples>>Hardware input output>>DAQmx>>analog measurements>>Voltage>> yopu will find Acq&Graph Voltage-Int Clk-Dig Start.vi
This example demonstrates how to acquire a finite amount of data (Waveform) using an internal sample clock, started by a digital edge.
This should satisfy the initial part of your requirement.
To be honest, I had not come across a case where I had to stop acq based on a reference Digital pulse.
So I am not sure how to stop acq using the same digital pulse

Maybe you can monitor the same digital start pulse on a seperate DIO line and use it to stop acq loop.
And logically thinking, you must have a check in your program wherein the initial 'off' state itself does not stop your acq loop, even before your acquisition recieves the 'on' start trigger.
Hope this helps
Regards
Dev