Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: How to show a progress bar in the main app thread? (Read 2967 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

How to show a progress bar in the main app thread?

Hello,

I am writing a plugin which processes a playlist and show the progress in a progress bar. Here comes a problem: when I use the threaded_process class to show the progress bar, I could not visit playlist_manager since the code runs in a new thread. Is there some way to show the progress bar in the main app thread? Or how can I access playlist_manager in threads other than the main one?

Thanks.


edit: sorry i confused the topic description with the topic title...

How to show a progress bar in the main app thread?

Reply #1
Or how can I access playlist_manager in threads other than the main one?
You can't, that's by design - making application-wide changes doable through main thread only serializes the access to these resources. Other components would not like it if the playlists got changed under their hands, for example during a global callback.

What kind of time-consuming operation are you performing with the playlists so that it requires showing a progress bar for the user?
You could get the necessary information in the main thread (either before starting completely or using [font= "Courier New"]main_thread_callback[/font]), then do whatever you need to do using [font= "Courier New"]threaded_process[/font], then make the changes in the main thread again (using the callback).
Full-quoting makes you scroll past the same junk over and over.


How to show a progress bar in the main app thread?

Reply #3
All right. I think you should only get a list of dead items in the main thread, then do all the costly matching in background, creating a map of old item => new item pairs ([font= "Courier New"]metadb_handle::ptr[/font]s should suffice), finally quickly commit the changes in the main thread again.
Full-quoting makes you scroll past the same junk over and over.