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: threaded process (Read 2542 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

threaded process

I'm unable to start a threaded process in the execute() function of a mainmenu_commands object.

Getting this: unhandled exeption: This method can be called only from the main thread

What I basically want to do is generate a playlist and this is initiated from the main menu. Because it can take a little time I would like to do this in the background.
What is the correct way to do this, or is this not possible?

 

threaded process

Reply #1
The correct way to use threaded_process is as follows:
  • Set up your data in threaded_process_callback::on_init(). This runs in the main thread, so you can grab data from the playlist_manager, for example.
  • Perform some (potentially) lengthy computation in threaded_process_callback::run(). This runs in a background thread.
  • Clean up and output data in threaded_process_callback::on_done(). This runs in the main thread again, so outputting data can mean to create a playlist.