<!--
{
  "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/performAndWait(_:)-6aaf1",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data",
      "CoreData"
    ],
    "preciseIdentifier" : "s:So22NSManagedObjectContextC8CoreDataE14performAndWaityxxyKXEKlF"
  },
  "title" : "performAndWait(_:)"
}
-->

# performAndWait(_:)

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

```
@preconcurrency nonisolated func performAndWait<T>(_ block: @Sendable () throws -> T) rethrows -> T
```

## Parameters

`block`

The closure to perform.

## Discussion

This method supports *reentrancy* — meaning it’s safe to call the method again, from within the closure, before the previous invocation completes.

---

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)