andersa@ellenshoej.dk Posted November 10, 2011 Share 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 6 Quote Link to comment Share on other sites More sharing options...
rsanford Posted November 10, 2011 Share Posted November 10, 2011 great, thanks Anders Quote Link to comment Share on other sites More sharing options...
fredycc Posted November 10, 2011 Share Posted November 10, 2011 Thanks Anders, very usefull example. Regards Quote Link to comment Share on other sites More sharing options...
morenolegal Posted July 14, 2014 Share Posted July 14, 2014 Thanks, nice example. Quote Link to comment Share on other sites More sharing options...
mhmda Posted July 15, 2014 Share Posted July 15, 2014 Very good example :-) Quote Link to comment Share on other sites More sharing options...
molla2005b Posted July 18, 2014 Share Posted July 18, 2014 great, thanks Anders Quote Link to comment Share on other sites More sharing options...
jefferson007 Posted August 7, 2015 Share Posted August 7, 2015 Very good,it's very useful! Quote Link to comment Share on other sites More sharing options...
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.