# `GSDispatchSyncMain`

*Function*

Runs the given block on the main queue synchronously.

## Declaration

```swift
func GSDispatchSyncMain(_ body: @escaping () -> Void)
```

```objc
void GSDispatchSyncMain(void (^body)());
```

```python
GSDispatchSyncMain(body)
```

## Discussion

If the function is called on the main queue, the block is invoked immediately. Otherwise, the block is dispatched synchronously on the main queue.

> **Warning**
> This can deadlock when the main queue is sync-dispatching another queue on which this function is called.

