---
title: "setEventHandler(handler:)"
framework: dispatch
role: symbol
role_heading: Instance Method
path: "dispatch/dispatchsourceprotocol/seteventhandler(handler:)"
---

# setEventHandler(handler:)

Sets the event handler work item for the dispatch source.

## Declaration

```swift
func setEventHandler(handler: DispatchWorkItem)
```

## Parameters

- `handler`: The event handler block to submit to the source’s target queue.

## Discussion

Discussion The event handler (if specified) is submitted to the source’s target queue in response to the arrival of an event.

## See Also

### Installing Event Handlers

- [setEventHandler(qos:flags:handler:)](dispatch/dispatchsourceprotocol/seteventhandler(qos:flags:handler:).md)
- [setRegistrationHandler(handler:)](dispatch/dispatchsourceprotocol/setregistrationhandler(handler:).md)
- [setRegistrationHandler(qos:flags:handler:)](dispatch/dispatchsourceprotocol/setregistrationhandler(qos:flags:handler:).md)
- [DispatchSourceProtocol.DispatchSourceHandler](dispatch/dispatchsourceprotocol/dispatchsourcehandler.md)
