In Delphi, is TDataSet thread safe?

前端 未结 6 1368
没有蜡笔的小新
没有蜡笔的小新 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 02:57

    Provided you only want to use the dataset in its own thread, you can just use synchronize to communicate with the main thread for any VCL/UI update, like with any other component.
    Or, better, you can implement communication between the mainthread and worker threads with your own messaging system.

    check Hallvard's solution for threading here:
    http://hallvards.blogspot.com/2008/03/tdm6-knitting-your-own-threads.html

    or this other one:
    http://dn.codegear.com/article/22411

    for some explanation on synchronize and its inefficiencies:
    http://www.eonclash.com/Tutorials/Multithreading/MartinHarvey1.1/Ch3.html

提交回复
热议问题