• 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: brain-dead NSThread question ...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: brain-dead NSThread question ...


  • Subject: Re: brain-dead NSThread question ...
  • From: Jason Coco <email@hidden>
  • Date: Sun, 14 Sep 2008 19:41:09 -0400


On Sep 14, 2008, at 19:36 , John Michael Zorko wrote:


Julien et al,


sleep() is just blocking the thread, so no event is processed. Use run loops instead.


Try to replace sleep() with [[NSRunLoop currentRunLoop] runMode:beforeDate:]

You mean the NSURLConnection callbacks are not callbacks in the C / C ++ sense i.e. they're more like dispatched messages instead?

They are like C callbacks but they get called from the RunLoop. The connection gets add as a run loop source and when data is ready, the call-back will get invoked.


The other problem that you have with your current implementation is that your main thread will completely block too. If this is a console app, that's not really a problem, but if this is a GUI app, it will stop responding to events and give the user a beach-ball... they will probably think that something is wrong and may kill the application, so you should watch out for that.

J

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________

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

References: 
 >brain-dead NSThread question ... (From: John Michael Zorko <email@hidden>)
 >Re: brain-dead NSThread question ... (From: "Julien Jalon" <email@hidden>)
 >Re: brain-dead NSThread question ... (From: John Michael Zorko <email@hidden>)

  • Prev by Date: Re: brain-dead NSThread question ...
  • Next by Date: Re: brain-dead NSThread question ...
  • Previous by thread: Re: brain-dead NSThread question ...
  • Next by thread: Re: brain-dead NSThread question ...
  • Index(es):
    • Date
    • Thread