• 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: How to update UI from a background thread
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to update UI from a background thread


  • Subject: Re: How to update UI from a background thread
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 21 Sep 2016 11:02:43 -0700

> On Sep 21, 2016, at 10:13 AM, Doug Hill <email@hidden> wrote:
>
> The symptoms you mention sound like a classic deadlock problem. That is, a code block running on the main queue schedules another code block on the main queue, but the original block never completes thus causing the app to hang or the new task never runs.

Worth noting that this can only occur if both of the cross-thread dispatches are synchronous. As long as one of them is async, there will be no deadlock. This is a very good reason for preferring async dispatches! If you need to return a value back to the original thread, or just perform something after the UI update finishes, the idiom is to issue another (nested) dispatch_async at the end of the first block, dispatching back to the background thread. That nested block can then perform the response/cleanup actions.

—Jens
_______________________________________________

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: 
 >How to update UI from a background thread (From: Dave <email@hidden>)
 >Re: How to update UI from a background thread (From: Sandor Szatmari <email@hidden>)
 >Re: How to update UI from a background thread (From: Dave <email@hidden>)
 >Re: How to update UI from a background thread (From: Quincey Morris <email@hidden>)
 >Re: How to update UI from a background thread (From: Doug Hill <email@hidden>)

  • Prev by Date: Re: How to update UI from a background thread
  • Next by Date: CALayer kCAGravityResizeAspectFill and kCAGravityTop
  • Previous by thread: Re: How to update UI from a background thread
  • Next by thread: Re: How to update UI from a background thread
  • Index(es):
    • Date
    • Thread