Q: Load list in "background"
#1
Hi,

at the moment, I load the whole directory at once, which might take a while.

is it possible to fill the directory incrementally, without blocking the GUI? (Kind of background thread that fills the directory)

I guess that I can launch a pyhton thread to do the background work, so can I notify the GUI to reload the directory from my addon?

dero
Reply
#2
I guess you are talking about a add-on of type "plugin", correct?
In plugins you can't add listitems asynchronous.

There are design-workarounds like using a pagination or using parent-folders for separate initials.

You could also show your code - maybe we can find a solution.
My GitHub. My Add-ons:
Image
Reply
#3
Yes, I am talking about a video plugin.

I build the list from many REST calls.

I guess I could spawn a thread to do this and then fill the directory from the current state of the background fetcher's results.

Is it possible to trigger a directory reload?

dero
Reply
#4
In theory yes, you could do a reload with
Code:
xbmc.executebuiltin("Container.Refresh()")
But your plugin should be started by the directory request and should exit itself after calling:
Code:
xbmcplugin.endOfDirectory(HANDLE)
My GitHub. My Add-ons:
Image
Reply
#5
Quote:But your plugin should be started by the directory request and should exit itself after calling:

What happens if there was still a thread running?
Reply
#6
The thread will run until completion. You need to design your plugin with this in mind so that you don't deadlock Xbmc when it tries to exit but has to wait for a thread to finish. A common method is to have the child thread check Xbmc.abortrequested() before doing anything and exit if it's true.
Reply
#7
Okay, so basically it's supported what I want... THANKS!
Reply

Logout Mark Read Team Forum Stats Members Help
Q: Load list in "background"0