---
title: dispatch_block_cancel
framework: dispatch
role: symbol
role_heading: Function
path: dispatch/dispatch_block_cancel
---

# dispatch_block_cancel

Cancels the specified dispatch block asynchronously.

## Declaration

```occ
extern void dispatch_block_cancel(dispatch_block_t block);
```

## Parameters

- `block`: The dispatch block to cancel. The result of passing NULL or a block object not returned by the doc://com.apple.dispatch/documentation/Dispatch/dispatch_block_create or doc://com.apple.dispatch/documentation/Dispatch/dispatch_block_create_with_qos_class function is undefined.

## Discussion

Discussion Cancellation causes any future execution of the dispatch block to return immediately, but does not affect any execution of the block object that is already in progress. Release of any resources associated with the block object is delayed until execution of the block object is next attempted (or any execution already in progress completes). note: Take care to ensure that a block object that may be canceled does not capture any resources that require execution of the block body in order to be released, such as memory allocated with malloc(3) on which the block body calls free(3). Such resources are leaked if the block body is never executed due to cancellation.

## See Also

### Canceling a Work Item

- [dispatch_block_testcancel](dispatch/dispatch_block_testcancel.md)
