<!--
{
  "documentType" : "article",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/dispatch-work-item",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "Dispatch Work Item"
}
-->

# Dispatch Work Item

The work you want to perform, encapsulated in a way that lets you attach a completion handle or execution dependencies.

## Discussion

A dispatch work item encapsulates work to be performed on a dispatch queue or within a dispatch group. You can also use a work item as a dispatch source event, registration, or cancellation handler.

## Topics

### Creating a Work Item

[`extern dispatch_block_t dispatch_block_create(dispatch_block_flags_t flags, dispatch_block_t block);`](/documentation/Dispatch/dispatch_block_create)

Creates a new dispatch block on the heap using an existing block and the given flags.

[`extern dispatch_block_t dispatch_block_create_with_qos_class(dispatch_block_flags_t flags, dispatch_qos_class_t qos_class, int relative_priority, dispatch_block_t block);`](/documentation/Dispatch/dispatch_block_create_with_qos_class)

Creates a new dispatch block from an existing block and the given flags, and assigns it the specified quality-of-service class and relative priority.

[`typedef void (^)(void) dispatch_block_t;`](/documentation/Dispatch/dispatch_block_t)

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

[`dispatch_block_flags_t`](/documentation/Dispatch/dispatch_block_flags_t)

### Scheduling Work Items

[`extern void dispatch_block_perform(dispatch_block_flags_t flags, dispatch_block_t block);`](/documentation/Dispatch/dispatch_block_perform)

Creates, synchronously executes, and releases a dispatch block from the specified block and flags.

### Adding a Completion Handler

[`extern void dispatch_block_notify(dispatch_block_t block, dispatch_queue_t queue, dispatch_block_t notification_block);`](/documentation/Dispatch/dispatch_block_notify)

Schedules a notification block to be submitted to a queue when the execution of a specified dispatch block has completed.

### Delaying Execution of a Work Item

[`extern intptr_t dispatch_block_wait(dispatch_block_t block, dispatch_time_t timeout);`](/documentation/Dispatch/dispatch_block_wait)

Waits synchronously until execution of the specified dispatch block has completed or until the specified timeout has elapsed.

### Canceling a Work Item

[`extern void dispatch_block_cancel(dispatch_block_t block);`](/documentation/Dispatch/dispatch_block_cancel)

Cancels the specified dispatch block asynchronously.

[`extern intptr_t dispatch_block_testcancel(dispatch_block_t block);`](/documentation/Dispatch/dispatch_block_testcancel)

Tests whether the given dispatch block has been canceled.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)