<!--
{
  "availability" : [
    "iOS: 5.0.0 -",
    "iPadOS: 5.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.7.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreData",
  "identifier" : "/documentation/CoreData/NSManagedObjectContext/perform(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Data"
    ],
    "preciseIdentifier" : "c:objc(cs)NSManagedObjectContext(im)performBlock:"
  },
  "title" : "perform(_:)"
}
-->

# perform(_:)

Asynchronously performs the specified closure on the context’s queue.

```
func perform(_ block: @escaping @Sendable () -> Void)
```

## Parameters

`block`

The closure to perform.

## Discussion

This method encapsulates an autorelease pool and a call to [`processPendingChanges()`](/documentation/CoreData/NSManagedObjectContext/processPendingChanges()).

---

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)