Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is TMemIniFile thread-safe?

Tags:

delphi

A user is getting an intermittent error "Cannot create file "C:...\Filename.ini". The requested operation cannot be performed on a file with a user-mapped section open."

I haven't been able to find much about this error that helps understand what's going on.

Is TMemIniFile thread-safe?

like image 1000
RobertFrank Avatar asked Dec 17 '22 14:12

RobertFrank


1 Answers

As far as I know TMemIniFile (and any other TCustomIniFile descendants) is not thread-safe. You will need to wrap it into a critical section.

In this link you can find an implementation of a thread-safe TCustomIniFile (theoretically programmed by Peter Below of TeamB though I can not assure it).

There is also a discussion in the Embarcadero forums about the thread-safety of TMemIniFile here. They speak about the C++ version of the component.

You can also find a discussion in MSDN regarding the origin of your error message here. It is a bit long but the general conclussion is that there are 2 exes trying to acces the same file. You can find another discussion on the subject here.

like image 65
Guillem Vicens Avatar answered Jan 02 '23 04:01

Guillem Vicens