What’s the proper way to handle data being written to the SD over time?
Scenario: Data incoming off the canbus at 8ms per packet, processing the data, and then updating the related objects. Another thread then writes the data from those related objects to the SD card.
I have a thread that writes the data (via FileStream.Write) at 50ms intervals and then a separate thread that flushes the FileStream every 1 second (I have tried 50ms and 30 sec no change)
The problem: The Flush call is blocking all other threads for sometimes up to 1480ms which causes my CAN keep alive thread to be blocked, and the DUT stops transmitting data.
My Question, what is the correct way to handle this situation? Should I flush often? or?
Am I right assuming that the data is stored in RAM until flushed to disk?
Thanks in advance