Posts: 964
Joined: Aug 2009
Reputation:
27
Popeye
Posting Freak
Posts: 964
2010-01-21, 22:07
I've done a few applications in Android and know from there the importance of threading long task's (such as loading a web page) not to lock up the UI. Quite a few XBMC plugins/scripts have the progressive bar dialog with the option to cancel. Often pressing cancel just results in a long wait for the task to be canceled. So is this due to the XBMC UI implementation or just poor threading in scripts or?
So I'm asking you skilled python coders, what is the best practice and you got any examples/snippets of good implementations?
Posts: 26,215
Joined: Oct 2003
Reputation:
187
It depends who handles the progress bar.
eg dir fetching cancellation by XBMC of plugins should be pretty quick as XBMC handles it.
However, if the progress bar is shown by the plugin then it may be them not checking it for cancellation at a suitable time period.
Cheers,
Jonathan
Posts: 33
Joined: Dec 2009
Reputation:
1
AFAIK, with plugins, you can't listen for the cancel button, you have to check it periodically. So that kind of defeats the point of launch the blocking code in separate threads from the UI so that the event handler can cancel those threads. In my NZB downloader, I update and check for cancellation at every step in initialization and after every article is decoded (they're about 500k each with a bunch of threads going on different articles, so it's fairly snappy).
Posts: 964
Joined: Aug 2009
Reputation:
27
Popeye
Posting Freak
Posts: 964
Aha! Great answers, thank you guys!