gpt4 book ai didi

iphone - 过早退出 dispatch_async ,Grand Central Dispatch

转载 作者:搜寻专家 更新时间:2023-10-30 20:12:36 24 4
gpt4 key购买 nike

假设我正在异步分派(dispatch)中运行一些代码。 .. 有没有办法在它完成之前终止它创建的线程?比如当用户点击取消

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{

//start doing something here.. break bofore it finishes?


dispatch_async(dispatch_get_main_queue(), ^{

//main thread stuff..

});



});

最佳答案

大卫是对的。 GCD 没有内置的取消方法。这取决于客户(您)。

关于iphone - 过早退出 dispatch_async ,Grand Central Dispatch,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4020362/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com