---
title: "init(name:priority:operation:)"
framework: swift
role: symbol
role_heading: Initializer
path: "swift/task/init(name:priority:operation:)-2dll5"
---

# init(name:priority:operation:)

Runs the given nonthrowing operation asynchronously as part of a new unstructured top-level task.

## Declaration

```swift
@discardableResult init(name: String? = nil, priority: TaskPriority? = nil, operation: sending @escaping @isolated(any) () async -> Success)
```

## Parameters

- `name`: Human readable name of the task.
- `priority`: The priority of the operation task.
- `operation`: The operation to perform.

## Return Value

Return Value A reference to the task.

## Discussion

Discussion You need to keep a reference to the task if you want to cancel it by calling the Task.cancel() method. Discarding your reference to a task doesn’t implicitly cancel that task, it only makes it impossible for you to explicitly cancel the task.

## See Also

### Creating a Task

- [init(name:priority:operation:)](swift/task/init(name:priority:operation:)-43wmk.md)
- [init(name:executorPreference:priority:operation:)](swift/task/init(name:executorpreference:priority:operation:)-59bfi.md)
- [init(name:executorPreference:priority:operation:)](swift/task/init(name:executorpreference:priority:operation:)-81pay.md)
- [currentPriority](swift/task/currentpriority.md)
- [basePriority](swift/task/basepriority.md)
- [withTaskPriorityEscalationHandler(operation:onPriorityEscalated:)](swift/withtaskpriorityescalationhandler(operation:onpriorityescalated:).md)
