0

What is the proper, most efficient way to perform a query in a second thread and update the GUI in a delphi xe5 iOS application ? Currently, I've been starting the spinner (TaniIndicator) animation from the main thread, then creating the second thread, which in turns perform the database query AND updates the GUI. Before applying the work in the second thread, the app worked fine (minus the usage of a smooth spinner), but Ive noticed now that I have the workload placed in a second thread, the app sometimes crashes. I've also noticed the more extensive the GUI update, the more often it crashes as well....

What is the best way (safest and most efficient) to perform a database query and update the GUI using threads? example; Should I be setting the parent of created controls in the second thread to, 'nil' ?

ThisGuy
  • 1,405
  • 1
  • 24
  • 51
  • This has been discussed a few hundred times here at least. You *don't* update the GUI from a thread without using `Synchronize` or `Queue`, both of which execute the UI update from the main thread. Neither the VCL or FMX GUI controls are thread safe. Read the large comment that the IDE automatically inserts into the unit if you use `File->New->Other` and create a new TThread Object, or search here for `[delphi] thread UI update`. – Ken White Nov 15 '13 at 16:56
  • Here's a starting point: http://stackoverflow.com/q/10648996/62576 – Ken White Nov 15 '13 at 17:02
  • 1
    Here's [another one](http://stackoverflow.com/q/18914314/62576) - see the first answer, not the question itself. It has a list of other posts related to this topic. – Ken White Nov 15 '13 at 17:12
  • I suggest asking a question about a specific case is better than asking for general knowledge. And a better fit for this Q&A forum. – LU RD Nov 15 '13 at 17:35

0 Answers0