• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Main Thread UI and Detached Thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Main Thread UI and Detached Thread


  • Subject: Re: Main Thread UI and Detached Thread
  • From: "Hank Heijink (Mailinglists)" <email@hidden>
  • Date: Mon, 31 Mar 2008 12:48:07 -0400

Just checking the obvious here - is it possible that your worker thread completes its work so fast that the main run loop hasn't updated the screen once before it's done? Keep in mind that the main thread has to display your window with the progress bar and the text and (depending on your implementation) that your worker thread may be working (and completing) while that's being done.

On Mar 30, 2008, at 2:55 PM, Mike wrote:
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:
@runbox.com


This email sent to email@hidden


_______________________________________________

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Main Thread UI and Detached Thread
      • From: Mike <email@hidden>
References: 
 >Main Thread UI and Detached Thread (From: Mike <email@hidden>)

  • Prev by Date: Re: Spaces Implementation
  • Next by Date: Re: core data and sqlite db store problem
  • Previous by thread: Re: Main Thread UI and Detached Thread
  • Next by thread: Re: Main Thread UI and Detached Thread
  • Index(es):
    • Date
    • Thread