---
title: "perform(inModes:block:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/runloop/perform(inmodes:block:)"
---

# perform(inModes:block:)

Schedules a block that the run loop invokes when it’s running in any of the specified modes.

## Declaration

```swift
func perform(inModes modes: [RunLoop.Mode], block: @escaping @Sendable () -> Void)
```

## Parameters

- `modes`: An array of modes in which the run loop invokes the block.
- `block`: The block that the run loop invokes.

## See Also

### Scheduling and Canceling Tasks

- [perform(_:)](foundation/runloop/perform(_:).md)
- [perform(_:target:argument:order:modes:)](foundation/runloop/perform(_:target:argument:order:modes:).md)
- [cancelPerform(_:target:argument:)](foundation/runloop/cancelperform(_:target:argument:).md)
- [cancelPerformSelectors(withTarget:)](foundation/runloop/cancelperformselectors(withtarget:).md)
