---
title: "readToEndOfFileInBackgroundAndNotify(forModes:)"
framework: foundation
role: symbol
role_heading: Instance Method
path: "foundation/filehandle/readtoendoffileinbackgroundandnotify(formodes:)"
---

# readToEndOfFileInBackgroundAndNotify(forModes:)

Reads to the end of file from the file or communications channel in the background and posts a notification when finished.

## Declaration

```swift
func readToEndOfFileInBackgroundAndNotify(forModes modes: [RunLoop.Mode]?)
```

## Parameters

- `modes`: The runloop modes in which the read completion notification can be posted.

## Discussion

Discussion See readToEndOfFileInBackgroundAndNotify() for details of this method’s operation. The method differs from readToEndOfFileInBackgroundAndNotify() in that modes specifies the run-loop mode (or modes) in which NSFileHandleReadToEndOfFileCompletion can be posted. You must call this method from a thread that has an active run loop.

## See Also

### Related Documentation

- [enqueue(_:postingStyle:coalesceMask:forModes:)](foundation/notificationqueue/enqueue(_:postingstyle:coalescemask:formodes:).md)

### Reading asynchronously with notifications

- [acceptConnectionInBackgroundAndNotify()](foundation/filehandle/acceptconnectioninbackgroundandnotify().md)
- [acceptConnectionInBackgroundAndNotify(forModes:)](foundation/filehandle/acceptconnectioninbackgroundandnotify(formodes:).md)
- [readInBackgroundAndNotify()](foundation/filehandle/readinbackgroundandnotify().md)
- [readInBackgroundAndNotify(forModes:)](foundation/filehandle/readinbackgroundandnotify(formodes:).md)
- [readToEndOfFileInBackgroundAndNotify()](foundation/filehandle/readtoendoffileinbackgroundandnotify().md)
- [waitForDataInBackgroundAndNotify()](foundation/filehandle/waitfordatainbackgroundandnotify().md)
- [waitForDataInBackgroundAndNotify(forModes:)](foundation/filehandle/waitfordatainbackgroundandnotify(formodes:).md)
