I'll try to take a look at your code when I get home.
We use TDMS to log to the RIO and review afterwards. The logging loop runs in Periodic Tasks and stores data to a buffer. Once per second the buffer is flushed to storage.
You can see how we did this in 2013 here:
http://www.chiefdelphi.com/media/papers/2876?