是否可以使dispatch_queue_t为空? [英] Is it possible to make dispatch_queue_t empty?

查看:145
本文介绍了是否可以使dispatch_queue_t为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到有关它的任何信息.我的应用程序中有一个dispatch_queue_t,我在其中放置了一些任务.但是这些任务需要一些时间,而且有时不应该再调用它们,因此我想清理队列.有可能吗?

I cannot find any information about it. I have a dispatch_queue_t in my application where I put some tasks to do. But these tasks take some time and it happens that sometimes they shouldn't be called any more so I would like to clean out queue. Is it possible?

推荐答案

使用NSOperationQueue来实现这些功能-更加方便.将操作添加到队列后,您可以取消它们,甚至在需要时甚至取消所有待处理的操作.

Use NSOperationQueue for these capabilities - much more convenient. After adding operations to a queue, you can cancel them and even cancel all pending operations if needed.

这是一个入门的好教程: http://www.raywenderlich.com/19788/how-to -use-nsoperations和nsoperationqueues

Here's a good tutorial to get you started: http://www.raywenderlich.com/19788/how-to-use-nsoperations-and-nsoperationqueues

这篇关于是否可以使dispatch_queue_t为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆