---
title: "ODQueryScheduleWithRunLoop(_:_:_:)"
framework: opendirectory
role: symbol
role_heading: Function
path: "opendirectory/odqueryschedulewithrunloop(_:_:_:)"
---

# ODQueryScheduleWithRunLoop(_:_:_:)

Retrieves results from a query asynchronously by scheduling the query in a run loop.

## Declaration

```swift
func ODQueryScheduleWithRunLoop(_ query: ODQueryRef!, _ runLoop: CFRunLoop!, _ runLoopMode: CFString!)
```

## Parameters

- `query`: The query.
- `runLoop`: The run loop.
- `runLoopMode`: The mode of the run loop.

## Discussion

Discussion This function spawns a new thread to execute the query in inRunLoop. When the query is complete, the query’s callback function is called with both inResults and inError set to NULL. To remove an incomplete query from its run loop, call ODQueryUnscheduleFromRunLoop(_:_:_:).

## See Also

### Related Documentation

- [ODQueryCallback](opendirectory/odquerycallback.md)

### Working with Queries

- [ODQueryCopyResults(_:_:_:)](opendirectory/odquerycopyresults(_:_:_:).md)
- [ODQueryCreateWithNode(_:_:_:_:_:_:_:_:_:)](opendirectory/odquerycreatewithnode(_:_:_:_:_:_:_:_:_:).md)
- [ODQueryCreateWithNodeType(_:_:_:_:_:_:_:_:_:)](opendirectory/odquerycreatewithnodetype(_:_:_:_:_:_:_:_:_:).md)
- [ODQueryGetTypeID()](opendirectory/odquerygettypeid().md)
- [ODQuerySetCallback(_:_:_:)](opendirectory/odquerysetcallback(_:_:_:).md)
- [ODQuerySetDispatchQueue(_:_:)](opendirectory/odquerysetdispatchqueue(_:_:).md)
- [ODQuerySynchronize(_:)](opendirectory/odquerysynchronize(_:).md)
- [ODQueryUnscheduleFromRunLoop(_:_:_:)](opendirectory/odqueryunschedulefromrunloop(_:_:_:).md)
