---
title: "addTaskUnlessCancelled(name:priority:operation:)"
framework: swift
role: symbol
role_heading: Instance Method
path: "swift/throwingtaskgroup/addtaskunlesscancelled(name:priority:operation:)"
---

# addTaskUnlessCancelled(name: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.

## Declaration

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

## Parameters

- `name`: Human readable name of this task.
- `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

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

## Discussion

Discussion This method doesn’t throw an error, even if the child task does. Instead, the corresponding call to ThrowingTaskGroup.next() rethrows that error.

## See Also

### Adding Tasks to a Throwing Task Group

- [addTask(priority:operation:)](swift/throwingtaskgroup/addtask(priority:operation:).md)
- [addTask(executorPreference:priority:operation:)](swift/throwingtaskgroup/addtask(executorpreference:priority:operation:).md)
- [addTask(name:priority:operation:)](swift/throwingtaskgroup/addtask(name:priority:operation:).md)
- [addTask(name:executorPreference:priority:operation:)](swift/throwingtaskgroup/addtask(name:executorpreference:priority:operation:).md)
- [addTaskUnlessCancelled(priority:operation:)](swift/throwingtaskgroup/addtaskunlesscancelled(priority:operation:).md)
- [addTaskUnlessCancelled(name:executorPreference:priority:operation:)](swift/throwingtaskgroup/addtaskunlesscancelled(name:executorpreference:priority:operation:).md)
- [addTaskUnlessCancelled(executorPreference:priority:operation:)](swift/throwingtaskgroup/addtaskunlesscancelled(executorpreference:priority:operation:).md)
- [addImmediateTask(name:priority:executorPreference:operation:)](swift/throwingtaskgroup/addimmediatetask(name:priority:executorpreference:operation:).md)
- [addImmediateTaskUnlessCancelled(name:priority:executorPreference:operation:)](swift/throwingtaskgroup/addimmediatetaskunlesscancelled(name:priority:executorpreference:operation:).md)
