如何在NSOperationQueue中暂停NSOperation?

编程入门 行业动态 更新时间:2024-10-24 11:18:05
本文介绍了如何在NSOperationQueue中暂停NSOperation?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我需要暂停一个运行的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?

推荐答案

请参阅:链接

此处来自苹果文档:

暂停和恢复队列如果您要发出临时停止执行操作,可以使用setSuspended:方法暂停相应的操作队列。

Suspending and Resuming Queues If you want to issue a temporary halt to the execution of operations, you can suspend the corresponding operation queue using the setSuspended: method.

暂停队列不会导致已执行的操作在任务中暂停。它只是阻止新操作被调度执行。您可以暂停一个队列以响应用户请求,暂停任何正在进行的工作,因为期望用户最终可能希望恢复该工作。

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?

本文发布于:2023-11-27 03:03:45,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636300.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何在   NSOperationQueue   NSOperation

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!