I would like to asynchronously load data in a TDataSet using a TThread descendant. Correct me if I'm wrong, but I suppose there couldn't be any problem if dataset isn't connected to any GUI control but.. What if TDataSet is linked to a TDataSource that's linked to a GUI control? Is myThread.synchronize needed?
Asked
Active
Viewed 127 times
1
-
3I think you'd better disconnect it until your thread is done. You can catch events and progress in that thread and update gui when needed. Of course,you want to synchronize() those update calls. – Tim3880 May 15 '15 at 23:55
-
1Yes, you must disconnect them because data links such as the one for DB grid does not update the control in a thread safe manner (the rest of the layers use direct calls). You can disconnect the data set from the data source by doing `DataSource.DataSet := nil;` and assign it back when you're done with your thread work, for instance. P.S., if you were calling dataset methods through `Synchronize`, you wouldn't need a thread. – TLama May 16 '15 at 07:35
-
After disconnecting, in cases which other threads doesn't change the DataSet object, I can work on TDataSet without any problem? – Hwau May 16 '15 at 14:35