<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.10.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Dispatch",
  "identifier" : "/documentation/Dispatch/dispatch_block_cancel",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Dispatch"
    ],
    "preciseIdentifier" : "c:@F@dispatch_block_cancel"
  },
  "title" : "dispatch_block_cancel"
}
-->

# dispatch_block_cancel

Cancels the specified dispatch block asynchronously.

```
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 [`dispatch_block_create`](/documentation/Dispatch/dispatch_block_create)     or [`dispatch_block_create_with_qos_class`](/documentation/Dispatch/dispatch_block_create_with_qos_class)     function is undefined.

## 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.

---

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)