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).
精彩评论