Skip navigation.
 
mlMain Thread UI and Detached Thread
FROM : Mike
DATE : Sun Mar 30 20:55:29 2008

I have all my UI running on my app's main thread. I have a worker thread
that I detach with detachNewThreadSelector:toTarget:withObject: (my
worker thread).

In my worker thread I do a tight processing loop and one of the things I
do in the loop is call two methods in the main thread to update the
display (a text message and progress bar) - via
performSelectorOnMainThread:withObject:waitUntilDone:modes.

However, when the loop runs in the spawned thread, the display doesn't
get updated. If I insert a sleep(1) call into the loop, then the display
  updates.

Why doesn't the main thread process the changes to the UI unless I call
sleep? I thought the whole idea of using a separate thread was so that
the main thread could continue to run on its own?

Thanks,

Mike

Related mailsAuthorDate
mlMain Thread UI and Detached Thread Mike Mar 30, 20:55
mlRe: Main Thread UI and Detached Thread j o a r Mar 31, 18:36
mlRe: Main Thread UI and Detached Thread Hank Heijink (Mail… Mar 31, 18:48
mlRe: Main Thread UI and Detached Thread Mike Mar 31, 20:02
mlRe: Main Thread UI and Detached Thread Mike Mar 31, 20:06
mlRE: Main Thread UI and Detached Thread Andy Klepack Mar 31, 20:10
mlRe: Main Thread UI and Detached Thread j o a r Mar 31, 20:11
mlRe: Main Thread UI and Detached Thread Hank Heijink (Mail… Mar 31, 20:26
mlRe: Main Thread UI and Detached Thread Matt Mashyna Mar 31, 20:30
mlRe: Main Thread UI and Detached Thread Mike Mar 31, 21:15
mlRe: Main Thread UI and Detached Thread Mike Mar 31, 21:20
mlRe: Main Thread UI and Detached Thread Mike Mar 31, 21:25
mlRe: Main Thread UI and Detached Thread Mike Mar 31, 21:28
mlRe: Main Thread UI and Detached Thread j o a r Mar 31, 21:47
mlRe: Main Thread UI and Detached Thread j o a r Mar 31, 22:02
mlRe: Main Thread UI and Detached Thread Ken Victor Mar 31, 22:23
mlRe: Main Thread UI and Detached Thread Mike Apr 4, 09:06
mlRe: Main Thread UI and Detached Thread Mike Apr 4, 09:08
mlRe: Main Thread UI and Detached Thread j o a r Apr 4, 09:24
mlRe: Main Thread UI and Detached Thread Scott Ribe Apr 4, 16:12
mlRe: Main Thread UI and Detached Thread Shawn Erickson Apr 4, 22:29