File.copy locks UI thread - how to show progress?
-
I have a loop that copies say 10 files from one folder to another. I'd like to show a progress bar so the user can see how many files have been copied.
I can print the progress to the console without issue and even assign the progress to a panel. But I'm unable to repaint the panel because the copy method seems to block the UI thread.
What can I do about it? Can we move the copy command to the loading thread? Or perhaps give it a progress callback like the extractZipFile command?
-
@d-healey Have you tried a background task? Since it uses another thread...
-
@ustk For the copy or for the progress bar? I remember a while back using a background thread for something and it caused my plugin to crash, I haven't played with them since.
-
Putting the move function onto a background thread seems to have done the trick! Just need to test it on each OS to make sure it's stable :)
-
@d-healey BackgroundTask is amazing, it unlocks a whole new world with e.g. python access.