Function

dispatch_after

Enqueues a block for execution at the specified time.

Declaration

void dispatch_after(dispatch_time_t when, dispatch_queue_t queue, dispatch_block_t block);

Parameters

when

The temporal milestone returned by dispatch_time or dispatch_walltime.

queue

The queue on which to submit the block. The queue is retained by the system until the block has run to completion. This parameter cannot be NULL.

block

The block to submit. This function performs a Block_copy and Block_release on behalf of the caller. This parameter cannot be NULL.

Discussion

This function waits until the specified time and then asynchronously adds block to the specified queue.

Passing DISPATCH_TIME_NOW as the when parameter is supported, but is not as optimal as calling dispatch_async instead. Passing DISPATCH_TIME_FOREVER is undefined.

See Also

Executing Tasks Asynchronously

dispatch_async

Submits a block for asynchronous execution on a dispatch queue and returns immediately.

dispatch_async_f

Submits an application-defined function for asynchronous execution on a dispatch queue and returns immediately.

dispatch_after_f

Enqueues an application-defined function for execution at the specified time.

dispatch_function_t

The prototype of functions submitted to dispatch queues.

dispatch_block_t

The prototype of blocks submitted to dispatch queues, which take no arguments and have no return value.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software