Help - Search - Members - Calendar
Full Version: How to show a progress bar in the main app thread?
Hydrogenaudio Forums > Hosted Forums > foobar2000 > Development - (fb2k)
hakase
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...
Yirkha
QUOTE (hakase @ Aug 8 2009, 07:30) *
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 main_thread_callback), then do whatever you need to do using threaded_process, then make the changes in the main thread again (using the callback).
hakase
thx Yirkha

The plugin i am writing
http://www.hydrogenaudio.org/forums/index....showtopic=73910

It is quite time-cosuming so i am planning to add a progress bar for it...
Yirkha
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 (metadb_handle::ptrs should suffice), finally quickly commit the changes in the main thread again.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.