Ok, I reply (partly) to my own question. I got the total number of samples that was read in the callback by using:
int read = 0;
DAQmxReadAnalogF64(taskHandle,nSamples,10.0,DAQmx_Val_GroupByChannel, data.get(), bufferSize, &read, NULL)
The read contained 500 000 and this was confusing me. Now I noticed that the variable contains the amount of samples read per _channel_ not by per task that I thought. So now I get the correct amount of samples per second.
But this still does not explain why following call:
DAQmxRegisterEveryNSamplesEvent(taskHandle, DAQmx_Val_Acquired_Into_Buffer, 500000, 0, &onSamplesRead, this)
causes the callback to be called every second. I would expect it to be called every 0.5 seconds as there is 1 million samples per second (two simultaneous sampling channels at 500 kHz)?
Does the nSamples parameter in DAQmxRegisterEveryNSamplesEvent mean that the callback is called after nSamples have been read for each channel in task? If so, the documentation should be fixed because it says:
nSamples uInt32 The number of samples after which each event should occur.