andersa@ellenshoej.dk Posted November 10, 2011 Posted November 10, 2011 This comes up kind of often. The progress bar in Unigui doesn't behave like you are used to in Delphi, because of the fact that the server and client actually runs asynchronously. So, in order to get the result you expect you are pretty much forced to implement a multithreaded solution. I think it is well worth noting here, that this is actually the Correct way to use the progress bar even in standard VCL applications as well and not doing it this way and perhaps using tricks like Application.ProcessMessages is inherently evil. The attached project shows a very basic example of a multithreaded application which uses a worker thread to do a task that takes a while to complete (it calls sleep one hundred times). Every time the thread returns from sleep it checks for termination from the UI, updates the progress count and goes back to sleep. When the progress count has reached 100 the thread terminates automatically. The UI inspects the progress of the worker thread at regular intervals using TUniTimer. It then updates the progress bar and returns control to the user. The user can request that the thread terminates by clicking a cancel button. ProgressBarExample.zip 1 6 Quote
fredycc Posted November 10, 2011 Posted November 10, 2011 Thanks Anders, very usefull example. Regards Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.