AppKit 是否线程安全?

发布于 2024-11-02 00:50:33 字数 153 浏览 4 评论 0原文

你能解释一下 AppKit 是否线程安全吗?我在哪里可以读到相关内容? (线程编程指南除外,因为本文档创建了更多问题而不是答案)。例如,我可以在单独的线程中验证 NSToolbar 的VisibleItems 吗?或者我可以在第二个线程中增加 NSProgressIndicator 的值吗?

Can you explain me is AppKit thread-safe or not? Where can I read about it? (Except Threaded Programming Guide because this documentation creates more question instead answers). For example can I validateVisibleItems of NSToolbar in separated thread? Or can I increment value of NSProgressIndicator in second thread?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌无敌 2024-11-09 00:50:33

不,这不是一般情况。您 不应向除主线程之外的任何 UI 对象发送消息

在您给出的具体示例中,您可以使用 performSelectorOnMainThread:withObject:waitUntilDone: 到绕过限制:

[myToolbar performSelectorOnMainThread: @selector(validateVisibleItems) 
                            withObject: nil
                         waitUntilDone: whatever];

No, it is not in general. You should not send messages to any UI objects except from the main thread.

In the specific example you give, you can use performSelectorOnMainThread:withObject:waitUntilDone: to get around the restriction:

[myToolbar performSelectorOnMainThread: @selector(validateVisibleItems) 
                            withObject: nil
                         waitUntilDone: whatever];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文