Description dispatchglobal and dispatchmain submit a block (i.e. the code between dispatchglobal or dispatchmain and its closing dispatchend statement) for asynchronous execution on a dispatch queue and return immediately.
Blocks can be nested and each block must be terminated with the dispatchend statement.
Parameters
Parameter
Description
after
Optional. Enqueues the block for execution at the specified time (seconds from now).
Variables
Variables declared outside a block are available inside the block but are immutable unless they are declared with the block statement.
Variables declared inside a block are mutable but not available outside the block.
Notes on GCD's behavior (whether using these statements or not)
These statements do not change GCD's scheduling and dispatch behavior. Even using the optional 'after' and 'priority' parameters, GCD decides when and in which order a queued thread executes.
Submitting a block of code to a queue does not mean immediate execution; GCD decides when it will execute the block.
Code sequentially following a dispatchend executes virtually immediately and could easily complete before the dispatched task completes (especially true for a dispatched task that might take more time). In other words, code after the dispatchendcannot/should not assume the dispatched task has completed.