开发者

Premature exit from dispatch_asycn , Grand Central Dispatch

Lets say i am running some co开发者_运维知识库de in dispatch async. .. is there a way to terminate the thread it creates before it completes? like when the user clicks cancel

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

    });



});


David is right. GCD has no built-in method of cancellation. It is up to the client (you).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜