Re: dispatch_sync(dispatch_get_main_queue() UI weirdness
Re: dispatch_sync(dispatch_get_main_queue() UI weirdness
- Subject: Re: dispatch_sync(dispatch_get_main_queue() UI weirdness
- From: Jens Alfke <email@hidden>
- Date: Fri, 05 Sep 2014 11:59:40 -0700
> On Sep 5, 2014, at 11:44 AM, Jonathan Guy <email@hidden> wrote:
>
> when the NSOpenPanel opens all kinds of weirdness is going on. The scroll views scroll very erratically if at all and the directories don't list properly.
Well, you've blocked one of the threads that services the global dispatch queue — it's stuck in a dispatch_sync call that won't return until the user dismisses the open panel. I don't know exactly what kinds of problems blocking the queue will cause, but it's definitely not a good idea. (The problems you report sound more severe than what I would guess would happen, but I definitely don't know how concurrent dispatch queues are implemented.)
You should rewrite your code to use dispatch_async instead. Then when the modal session completes, call back to the global dispatch queue to finish running your code.
(And the whole scenario you're giving sounds like bad UI design — your code shouldn't suddenly pop up a modal panel just because you "need a file from the user". The user should be in control of tasks like opening files. But you may have created an unrealistic scenario just as an example…)
—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