I have written an application that samples analog input channels continuously. Now I want to add a feature to create an analog output signal. However, all examples that I've seen so far only write to buffer only once. In my use case I need to output a signal with a high sample rate (> 200 kHz) and a long duration (several minutes to hours). Thus I will need to update the output buffer multiple times while the analog output generation is running.
It is important that there are no gaps between the buffers in the output signal, also if my application is to slow in filling the buffer I wish to get an underflow exception or at least be able to detect it from my software.
What is the recommended way to implement this in C#? From the documentation I think I should be able to use AnalogSingleChannelWriter.BeginWriteMultiSample/EndWrite with the callback to repeatably fill the buffer. Alternatively, I believe I could create a separate thread and call WriteMultiSample in a loop.