Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Main Thread UI and Detached Thread



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



_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden


Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.