문제

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top