NSThread 的产量?
我有一个 NSOperationQueue,我想取消一些操作。因此我迭代操作并取消一些任务。在同一(UI)线程中随后执行的代码中的另一点,我检查队列中有多少操作。即使我取消所有操作,我也永远不会得到0。我猜这些操作需要正确处理取消。因此,我需要在取消后在我的 UI 线程中调用某种“yield”函数。有没有办法在 Cocoa Touch 中做到这一点?
我相当黑客的解决方案是取消后:
[NSThread sleepForTimeInterval:0.1];
知道如何让它变得更好吗?
谢谢, 拉尔斯
I have an NSOperationQueue and I want to cancel some operations. Therefore I iterate over the operation and cancel some tasks. At another point in the code which is executed subsequent in the same (UI) thread I check how many operations are in the queue. Even if I cancel all operations I get never 0. I guess the operations need to process the cancel properly. Therefore I would need some kind of "yield" function called in my UI thread after canceling. Is there a way to do that in Cocoa Touch?
My rather hackish solution is after cancel is:
[NSThread sleepForTimeInterval:0.1];
Any idea how to make that nicer?
Thanks,
Lars
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论