<!--
{
  "availability" : [
    "iOS: 15.0.0 -",
    "iPadOS: 15.0.0 -",
    "macCatalyst: -",
    "macOS: 12.0.0 -",
    "tvOS: 15.0.0 -",
    "visionOS: -",
    "watchOS: 8.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSManagedObjectContext/perform(schedule:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data",
      "CoreData"
    ],
    "preciseIdentifier" : "s:So22NSManagedObjectContextC8CoreDataE7perform8schedule_xAbCE17ScheduledTaskTypeO_xyKctYaKlF"
  },
  "title" : "perform(schedule:_:)"
}
-->

# perform(schedule:_:)

Submits a closure to the context’s queue for asynchronous execution.

```
@preconcurrency nonisolated func perform<T>(schedule: NSManagedObjectContext.ScheduledTaskType = .immediate, _ block: @escaping @Sendable () throws -> T) async rethrows -> T
```

## Parameters

`schedule`

The required execution schedule. For more information, see [`NSManagedObjectContext.ScheduledTaskType`](/documentation/CoreData/NSManagedObjectContext/ScheduledTaskType).

`block`

The closure to perform.

## Discussion

---

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)