<!--
{
  "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/UnsafeCurrentTask/isCancelled",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "Swift"
    ],
    "preciseIdentifier" : "s:Sct11isCancelledSbvp"
  },
  "title" : "isCancelled"
}
-->

# isCancelled

A Boolean value that indicates whether the current task was canceled.

```
var isCancelled: Bool { get }
```

## Discussion

After the value of this property becomes `true`, it remains `true` indefinitely.
There is no way to uncancel a task.

This property returns the actual cancellation state of the task, regardless of whether
a cancellation shield is active. Use [`isCancelled`](/documentation/Swift/Task/isCancelled-swift.type.property) (the static property)
if you need cancellation checking that respects active shields.

### Instance property isCancelled ignores Task Cancellation Shields

The instance property `task.isCancelled`
is not contextual and therefore does not respect cancellation shields. If a task
was cancelled and is executing
with an active cancellation shield, this property will return the *actual*
cancellation status of the specific task.

It is possible to determine if a shield is active and then actively determine
that the cancelled status should be temporarily ignored by using this pair of APIs:

```swift
withUnsafeCurrentTask { unsafeTask in
  if unsafeTask.hasActiveCancellationShield {
    false
  } else {
    unsafeTask.isCancelled
  }
}
```

Which is equivalent to the contextually aware static `Task.isCancelled` property:

```swift
// Contextually aware, and equivalent to the snippet using UnsafeCurrentTask:
Task.isCancelled
```

Prefer using [`isCancelled`](/documentation/Swift/Task/isCancelled-swift.type.property) (the static property) in most
situations when checking the cancellation status from inside the task.

> SeeAlso: ``doc://com.apple.Swift/documentation/Swift/Task/isCancelled-swift.type.property``

> SeeAlso: ``doc://com.apple.Swift/documentation/Swift/Task/checkCancellation()``

> SeeAlso: ``doc://com.apple.Swift/documentation/Swift/Task/hasActiveCancellationShield``

> SeeAlso: ``withTaskCancellationShield(operation:)-(()->Value)``

---

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)