Delphi Tip – FMX Update a progress bar within work loop.
Your application must do some work which blocks the main thread, and your progress indicator does not update until the job is done. Under windows you might have introduced “Application.ProcessMessages()” but this is not cross platform and can cause serious performance problems under FMX. What can you do about it?
This is precisely the question one of my customers posed to me recently. His application would poll a port within a while loop, and update a progress bar. My suggestion was that he use the threading library to move the polling work into a separate thread, and I wrote the attached sample application to demonstrate.
Unfortunately, in this customers case the port is tied to the main thread also, so this solution didn’t work for him, we’re exploring alternative options. I decided however that this sample might be useful for others without the single-thread constraint, and wanted to share it with you here…
Download the sample: here