Re: Open a panel in secondary thread?
Re: Open a panel in secondary thread?
- Subject: Re: Open a panel in secondary thread?
- From: Sandor Szatmari via Cocoa-dev <email@hidden>
- Date: Sun, 22 Mar 2020 20:32:25 -0400
> On Mar 22, 2020, at 6:20 PM, Steve Mills via Cocoa-dev
> <email@hidden> wrote:
>
>
>>
>> On Mar 22, 2020, at 15:38, Rob Petrovec via Cocoa-dev
>> <email@hidden> wrote:
>>
>> I would not do this. It is widely documented that AppKit API that produce
>> UI elements, like NSOpenPanel, are _not_ thread safe.
>
> The code shown *is* threadsafe. It’s calling it on the main thread.
The only issue I see is that if this code were ever called on the main thread.
I don’t know if this is likely because we don’t know enough about the OP’s
code. But if there is a chance a simple test would suffice.
if ( [NSThread isMainThread] )
// call code directly
else
// call dispatch_sync(…)
Sandor
>
> Steve via iPad
>
>
> _______________________________________________
>
> 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
_______________________________________________
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