Is there a way to manually block a queue task? I want to use UIView animation inside a dispatch queue task, but this task should only get finished when the animation is completed.
dispatch_queue_t myCustomQueue;
myCustomQueue = dispatch_queue_create("com.example.MyCustomQueue", NULL);
dispatch_async(myCustomQueue, ^{
[UIView animateWithDuration:myDuration
delay:0.0f
options:0
animations:^{
// my changes here
}
completion:nil];
});
dispatch_async(myCustomQueue, ^{
// if the animation from the task below is still running, this task should wait until it is finished...
});
Suspend your queue using
dispatch_suspendand then resume it (usingdispatch_resume) in your animation completion block. This will cause all blocks submitted to the queue to wait for the animation to complete before they are started. Note that blocks already running on that queue when you suspend it will continue running.