---
title: "run(resultType:body:)"
framework: swift
role: symbol
role_heading: Type Method
path: "swift/mainactor/run(resulttype:body:)"
---

# run(resultType:body:)

Execute the given body closure on the main actor.

## Declaration

```swift
static func run<T>(resultType: T.Type = T.self, body: @MainActor @Sendable () throws -> T) async rethrows -> T where T : Sendable
```
