问题描述
我需要暂停一个运行的NSOperation插入一个NSOperationQueue。目前我取消所有操作并重新启动它们。但这将导致在所完成的过程中出现某种重复。我尝试使用NSOperationQueue的setSuspended标志。但它不会暂停操作。有什么办法吗?
I need to pause a running NSOperation which was inserted in an NSOperationQueue. Currently I am canceling all operations and restarting them. But this would lead to some kind of duplication in terms of process done. I tried with setSuspended flag of NSOperationQueue. But it's not suspending the operation. Is there any way out?
推荐答案
请参阅:
此处来自:
暂停队列不会导致已执行的操作在任务中暂停。它只是阻止新操作被调度执行。您可以暂停一个队列以响应用户请求,暂停任何正在进行的工作,因为期望用户最终可能希望恢复该工作。
Suspending a queue does not cause already executing operations to pause in the middle of their tasks. It simply prevents new operations from being scheduled for execution. You might suspend a queue in response to a user request to pause any ongoing work, because the expectation is that the user might eventually want to resume that work.
这篇关于如何在NSOperationQueue中暂停NSOperation?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!