In Delphi, is TDataSet thread safe?

前端 未结 6 1364
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 02:30

I\'d like to be able to open a TDataSet asynchronously in its own thread so that the main VCL thread can continue until that\'s done, and then have the main VCL thread read

6条回答
  •  抹茶落季
    2021-01-02 03:16

    Also remember the thread will most likely need its own database connection. I believe what is needed here is a multi-threaded "holding" object to load the data from the thread into (write only) which is then read only from the main VCL thread. Before reading use some sort of syncronization method to insure that your not reading the same moment your writing, or writing the same moment your reading, or load everything into a memory file and write a sync method to tell the main app where in the file to stop reading.

    I have taken the last approach a few times, depdending on the number of expected records (and the size of the dataset) I have even taken this to a physical disk file on the local system. It works quite well.

提交回复
热议问题