First of all, I am assuming that the particular threading configuration that is causing the problem reported is that there are multiple TMemIniFile
instances, possibly even in different processes, being saved simultaneously from different threads.
TMemIniFile
is not thread-safe. To avoid any race conditions you need to write (pseudo-)code like this:
AcquireLock;
Try
ReadMemIniFileFromDisk;
ModifyMemIniFileInMemory;
WriteMemIniFileToDisk;
Finally
ReleaseLock;
End;
It's not enough to lock around just the file operations because then you may lose changes due to a race. You have to lock the entire read/modify/write cycle.