Premature exit of dispatch_asycn, Grand Central Dispatch

Lets say that I'm running some code in async sending ... is there a way to complete the created thread before it finishes? for example, when a user clicks a button

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

    });



});
+3
source share
1 answer

David is right. GCD does not have a built-in undo method. It depends on the client (you).

+3
source

Source: https://habr.com/ru/post/1771418/


All Articles