Premature exit from dispatch_asycn , Grand Central Dispatch
-
26-09-2019 - |
문제
Lets say i am running some code 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).
제휴하지 않습니다 StackOverflow