0Pricing
Swift Academy · Lesson

Task and Task Cancellation

Creating structured tasks, checking cancellation and cooperative cancellation.

Welcome

`Task` is the fundamental unit of concurrency in Swift. It runs async work and supports structured cancellation for clean resource management.

Creating a Task

```swift Task { let user = try await fetchUser(id: 1) print(user.name) } ``` `Task` creates a new concurrent execution context.

All lessons in this course

  1. async/await Syntax and Calling Async Functions
  2. Task and Task Cancellation
  3. async let and Concurrent Child Tasks
  4. Actors: Protecting Shared Mutable State
← Back to Swift Academy