Friday, May 6, 2011

Loading a view on a background thread

Is it possible to load a view on a background thread?

I am using buffering to render views into a buffer off screen so they can be scrolled into view later. I want to make the UI more response and it seems to be the off screen buffering that is the culprit, and am wondering if I can load up the buffered view on a background thread as I don't need it available immediately. The problem with doing this seems to be that the thread has its own auto release pool, which then gets cleared when the thread exits. Is it possible for the background thread and the ui thread to share memory or a pool?

From stackoverflow
  • Secondary thread should have it's own autorelease pool. Which should be released if the secondary thread exists.

    When you pass data between threads the sender should retain it and the receiver thread should release/autorelease it. But in most cases this is done "automatically", if you're using properties or performSelectorOnMainThread for example.

    Roger Nolan : ...and note that all UI updates should be performed on the main thread.
    Ian1971 : Interesting comment Roger. Could you go into more detail? Is it possible for me to load the view at all on the secondary thread?
    Ian1971 : performSelectorOnMainThread was what I needed

0 comments:

Post a Comment