multithreadingdelphifiremonkeydelphi-xe7livebindings

Is there an alternative to LiveBindings in FMX so I can use datasets generated by a thread?


Right now my FMX project is totally based on Livebinding to connect the datasources to my editors on the form.

It works nice, besides to be slow and do not use paging loading (TLisView).

However, I have many different datasources and the amount of data can be huge and connections eventually slow.

My idea is to keep the user interface responsive and let threads in the background make the data load opening the datasources and put them it the right state. After that assigning the datasource to the controls on the form.

I have played with that with LiveBinding but I cannot mix the main thread with background ones. Some problems happened.

Having to load each field record to each control manually seems to be extremely unproductive. I have almost all the controls that I use already wrapped, I made my own controls based on the FMX ones, so I can have the possibility to add more functions.

I was wondering if there is something already done. Any class or library that I could use to map the source and targets and that I can have the control to activate when it is needed, since I can have many datasources in loading state by a thread.


Solution

  • This is not really a livebinding question.

    Also without livebindings, when you retrieve data in a thread you have to respect the thread context. When getting a dataset from a connection, this dataset is also bound to that connection and the connection is bound to the thread context.

    The solution is to copy the dataset into a clientdataset and hand over that CDS to the UI thread. Now you can bind that CDS wherever you like. Remember, that there is no connection between the CDS and the data connection. You have to take care yourself writing back the changes.