The DAQmxRegisterEveryNSamplesEvent registers a callback
function to receive an event when the specified number of samples is written
from the device to the buffer or from the buffer to the device. (see the NI-DAQmx C Reference Help for more
information about this function). So if
I have an analog input task, and I specify 1000 samples in the DAQmxRegisterEveryNSamplesEvent
function, and I create a callback function that performs a digital read, my
digital read function will be fired as soon as 1000 samples of the analog input
task have been transferred to the buffer.
In your case your EveryNSamplesEventHandler
function (which has your
DAQmxReadBinary16 function), will be fired as soon as the number of samples you
specified when you registered the event have been transferred to the buffer.
As
far as your other questions about the DAQmxGetTaskNumChans function, I do not
believe you need to use this function if you already know the number of samples
or channels that you will be using. One
of the advantages for using it, however, are if you ever need to changed the
number of samples or channels in your code, you will only need to change this
information in one place, instead of two.
It helps to make the code more modular and easier to maintain.
Hope
this helps.