<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "os",
  "identifier" : "/documentation/os/os_workgroup_cancel",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "os"
    ],
    "preciseIdentifier" : "c:@F@os_workgroup_cancel"
  },
  "title" : "os_workgroup_cancel"
}
-->

# os_workgroup_cancel

Cancels and invalidates the specified workgroup.

```
extern void os_workgroup_cancel(os_workgroup_t wg);
```

## Parameters

`wg`

The workgroup you want to cancel.

## Discussion

After you cancel a workgroup, don’t schedule any more work on it. New threads may not join a canceled workgroup, but may still leave it. Most other calls to workgroup APIs return an appropriate error for a canceled workgroup, but otherwise do nothing.

To handle cancellation, call the [`os_workgroup_testcancel`](/documentation/os/os_workgroup_testcancel) function periodically from your thread code to monitor the state of the workgroup. If that function returns `true`, stop all workgroup-related tasks and call `os_workgroup_leave_self` to remove the thread from the workgroup. Cancellation of a workgroup affects the immediate workgroup only, and doesn’t affect other related workgroups. For example, if you created a workgroup using the [`os_workgroup_create_with_workgroup`](/documentation/os/os_workgroup_create_with_workgroup) function, cancel the original workgroup and the copy of it separately.

---

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)