Wish Progress Dialog/Indicator on other thread

BarryW

Active Member
Licensed User
Longtime User
Hi masters. Im wishing for a progress dialog or indicator than runs on another thread smoothly... Because using doevents inside a process or in a loop runs the progressbar but with some hangs... Tnx...
 

aidymp

Well-Known Member
Licensed User
Longtime User
It is not possible. Only the main thread can update the UI.

What are you doing in the loop that slows down the main thread?

I am deleting lots of files and folders! and cannot update the UI at all! So I have a "please wait..." image!!
 

BarryW

Active Member
Licensed User
Longtime User
Please wait image is good but its not moving... i prefer to used progressbar to make a good gui... Tnx to ur reply...
 

JohnK

Active Member
Licensed User
Longtime User
Please wait image is good but its not moving... i prefer to used progressbar to make a good gui... Tnx to ur reply...
Use a thread for everything that is not performed on the GUI, that leaves the GUI thread totally free to display and update a progress indicator.
 

aidymp

Well-Known Member
Licensed User
Longtime User
Use a thread for everything that is not performed on the GUI, that leaves the GUI thread totally free to display and update a progress indicator.

Are you able to delete large folders say 1gb+ (1000s of files) and update the UI? I get either a very stuttery update or nothing!

Any tips

Thanks

Aidy
 

JohnK

Active Member
Licensed User
Longtime User
I have not tried it myself, but the threading library by agraham has a priority property, so maybe if you perform the delete on a thread with the priority set low, you may get better response in your GUI. also, even though it would most likely severely slow things down, instead of deleting all files in a single command, if you loop through the file list with a sleep (or doevents) this step would also allow more cpu clicks for the GUI to update. Without knowing your projects or testing the theory, however, if you are deleting every file in a directory containing 000's of files, it may be quicker to drop the directory itself, and then recreate it afterwards rather than deleting the individual files. Just some thoughts, hope it helps.
 

Informatix

Expert
Licensed User
Longtime User
I have not tried it myself, but the threading library by agraham has a priority property, so maybe if you perform the delete on a thread with the priority set low, you may get better response in your GUI. also, even though it would most likely severely slow things down, instead of deleting all files in a single command, if you loop through the file list with a sleep (or doevents) this step would also allow more cpu clicks for the GUI to update. Without knowing your projects or testing the theory, however, if you are deleting every file in a directory containing 000's of files, it may be quicker to drop the directory itself, and then recreate it afterwards rather than deleting the individual files. Just some thoughts, hope it helps.
Deleting a large number of files should always be done in another thread. Google recommends to do all disks and network operations in the background. You can do that either with the threading library or with my CallSubExtended library.
 

aidymp

Well-Known Member
Licensed User
Longtime User
I have not tried it myself, but the threading library by agraham has a priority property, so maybe if you perform the delete on a thread with the priority set low, you may get better response in your GUI. also, even though it would most likely severely slow things down, instead of deleting all files in a single command, if you loop through the file list with a sleep (or doevents) this step would also allow more cpu clicks for the GUI to update. Without knowing your projects or testing the theory, however, if you are deleting every file in a directory containing 000's of files, it may be quicker to drop the directory itself, and then recreate it afterwards rather than deleting the individual files. Just some thoughts, hope it helps.


You say drop the directory! how would I do that? As that was what I wanted to do originally. But only found a way of removing individual files

Thanks

Aidy
 

wonder

Expert
Licensed User
Longtime User
It may be overkill, but using LibGDX might do the trick.
In my project, when I was doing a lot of disk operations (unnecessarily*), my loading animation was being smoothly displayed at 60fps.

*I fixed it.
 
Top