Process cannot access the file because it is being used by another proess

So one of the issues with my approach was that the serial port information was being read in so quickly and in multiple places that the calls became almost simultaneous. A quick fix(hack) was the add a slight delay before or after the call which seemed to do the job, however an easier fix would be to limit the number of calls made to the function from the serial port, as this would ensure that the file is always open for use, as the SaveReadingLogToFile() isn’t being called multiple times from different threads/places. The best fix for this i feel, would be to write the operations to a queue and/or add a lock around the writing of the file.

Leave a Comment