Re: How to update UI from a background thread
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