【问题标题】:Premature exit from dispatch_asycn , Grand Central Dispatch过早退出 dispatch_async , Grand Central Dispatch
【发布时间】:2010-10-26 02:56:00
【问题描述】:

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

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..   

    });



});

【问题讨论】:

标签: iphone objective-c multithreading grand-central-dispatch


【解决方案1】:

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

【讨论】:

    猜你喜欢
    • 2012-05-09
    • 1970-01-01
    • 1970-01-01
    • 2011-07-28
    • 2023-03-25
    • 1970-01-01
    • 2012-11-27
    • 2011-06-04
    相关资源
    最近更新 更多