<!--
{
  "availability" : [
    "macOS: 10.7.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppKit",
  "identifier" : "/documentation/AppKit/NSDocument/continueAsynchronousWorkOnMainThread(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "AppKit"
    ],
    "preciseIdentifier" : "c:objc(cs)NSDocument(im)continueAsynchronousWorkOnMainThreadUsingBlock:"
  },
  "title" : "continueAsynchronousWorkOnMainThread(_:)"
}
-->

# continueAsynchronousWorkOnMainThread(_:)

Invokes the passed-in block on the main thread.

```
nonisolated func continueAsynchronousWorkOnMainThread(_ block: @escaping () -> Void)
```

## Parameters

`block`

The block to be invoked.

## Discussion

If the main thread is blocked by an invocation of [`performActivity(withSynchronousWaiting:using:)`](/documentation/AppKit/NSDocument/performActivity(withSynchronousWaiting:using:)) or [`performSynchronousFileAccess(_:)`](/documentation/AppKit/NSDocument/performSynchronousFileAccess(_:)), this method interrupts that blocking activity, performs the specified `block`, and then resumes the blocking activity after `block` returns. Invocations of this method always return before the passed-in block is invoked.

You can invoke this method when work is being done on a non-main thread and part of the work must be continued on the main thread. For example, [`save(to:ofType:for:completionHandler:)`](/documentation/AppKit/NSDocument/save(to:ofType:for:completionHandler:)) uses this method when it has just completed the actual writing of the file during asynchronous saving and, to finish the saving operation, must invoke [`updateChangeCount(withToken:for:)`](/documentation/AppKit/NSDocument/updateChangeCount(withToken:for:)) and other methods on the main thread.

This method can be invoked on any thread.

---

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)