This example demonstrate how to measure the pulse width of an signal.
Background:
Using normal DAQmx "Counter - Read Pulse Width and Frequency (Finite).vi" Example requires more than one switch event (Buffer Size) and requires that you select a timeout time for the DAQmx read function. You could wire there -1 which results in an endless wait until the required samples are acquired. But then you need to abort this VI (no DAQmx close) when the required samples couldn't be acquired.
How to use example:
Idea behind this example:
You register a dynamic DAQmx Event on the amount of Pulse Widths you want acquire. When the samples are acquired DAQmx is fire an Event which is handled from event structure. In this SubCase you run the DAQmx Read function with size of already acquired samples in buffer. So DAQmx Read should never run into a timeout and your acquisition can every time be stopped. (inkl. free all references)
Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.