<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Swift",
  "identifier" : "/documentation/Swift/TaskGroup/addTaskUnlessCancelled(priority:operation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:ScG22addTaskUnlessCancelled8priority9operationSbScPSg_xyYaYAcntF"
  },
  "title" : "addTaskUnlessCancelled(priority:operation:)"
}
-->

# addTaskUnlessCancelled(priority:operation:)

Adds a child task to the group, unless the group has been canceled.
Returns a boolean value indicating if the task was successfully added to the group or not.

```
mutating func addTaskUnlessCancelled(priority: TaskPriority? = nil, operation: sending @escaping @isolated(any) () async -> ChildTaskResult) -> Bool
```

## Parameters

`priority`

The priority of the operation task.
Omit this parameter or pass `nil` to inherit the task group’s base priority.

`operation`

The operation to execute as part of the task group.

## Return Value

`true` if the child task was added to the group;
otherwise `false`.

---

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)