Suggestion request in concurrency problem lazarus / 16-Databases ---------------------------------------------------------------------- esvignolo · 2017-02-03 20:42 Hello everyone, I have a problem that I have to see with a table (tbufdatset) and access to it. The scenario is as follows: a main form that contains the table in memory(tbufdatset), but the data of the same is updated by a thread from time to time. The problem occurs when you are updating the table in memory (by the thread) and at the same time from the main form you want to query the same tbufdatset, and this generates memory access errors. Ideally update in a second table in memory, and once the second is updated, this happens to be the main one, but I can not think how to do it. The suggestions are appreciated, thank you very much. ---------------------------------------------------------------------- LacaK · 2017-02-04 15:30 You must protect code which modifies/reads TBufDataset using any kind of synchronization. See for example: http://wiki.freepascal.org/Multithreaded_Application_ Tutorial#Critical_sections ---------------------------------------------------------------------- esvignolo · 2017-02-04 16:48 Hi LacaK, thanks for your answer. I am already using critical sections in similar parts, but in the case of the table in memory, the main form that reads the tbufdataset in 99% of the time only reads it, and the process of the thread that updates it can take a minute, Which, thought or tried to find a solution where the load of the thread is generated in a second tbufdataset, so that when this process of one minute is finished, become the tbufdataset that uses the main form, and not have "on hold" reading the main form. Quote from: LacaK on February 04, 2017, 04:30:46 pmYou must protect code which modifies/reads TBufDataset using any kind of synchronization. See for example: http://wiki.freepascal.org/Multithreaded_Application_ Tutorial#Critical_sections