• 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: waiting for async callback in main thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: waiting for async callback in main thread


  • Subject: Re: waiting for async callback in main thread
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Wed, 28 Oct 2009 00:37:06 +0100


Le 27 oct. 2009 à 21:47, Alexander Cohen a écrit :


On Oct 27, 2009, at 3:42 PM, Jens Alfke wrote:


On Oct 27, 2009, at 12:11 PM, Alexander Cohen wrote:

100% agree with you, and that's what i would normally do. But unfortunately, this time i must wait in the mainthread for the callback. I know it's wrong, but this time i've gotta do it.

Then use a while loop to run the runloop until your callback's been invoked. The reason this is described as wrong is because it blocks the main thread; but if you have to block the main thread, this is the way to do it.

Excellent. I remember reading somewhere that because of changes in 10.6 to the way the runLoop works, it was a bad idea to do this. But for now its working and until someone tells me otherwise, this'll do.


thx

According to the CFRunLoop reference (CFRunLoopRun() discussion to be exact), it is perfectly valid to call a runloop recursively.


«Run loops can be run recursively. You can call CFRunLoopRun from within any run loop callout and create nested run loop activations on the current thread’s call stack.»

If you encounter any issue with this function (but look like it's not the case), fill a radar.

-- Jean-Daniel




_______________________________________________

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: waiting for async callback in main thread
      • From: John Engelhart <email@hidden>
References: 
 >waiting for async callback in main thread (From: Alexander Cohen <email@hidden>)
 >Re: waiting for async callback in main thread (From: Jens Alfke <email@hidden>)
 >Re: waiting for async callback in main thread (From: Alexander Cohen <email@hidden>)
 >Re: waiting for async callback in main thread (From: Jens Alfke <email@hidden>)
 >Re: waiting for async callback in main thread (From: Alexander Cohen <email@hidden>)

  • Prev by Date: Re: Interrupting auto-expansion in NSOutlineView
  • Next by Date: Re: Alternative to stringWithContentsOfURL
  • Previous by thread: Re: waiting for async callback in main thread
  • Next by thread: Re: waiting for async callback in main thread
  • Index(es):
    • Date
    • Thread