---
title: SetHandler
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/iotimerdispatchsource/sethandler
---

# SetHandler

Sets the handler block to run when the timer fires.

## Declaration

```occ
virtual kern_return_t SetHandler(OSAction *action);
```

## Parameters

- `action`: The doc://com.apple.driverkit/documentation/DriverKit/OSAction object that contains your custom callback method. The dispatch source object retains your action object until you call this method again or cancel the dispatch source.

## Return Value

Return Value kIOReturnSuccess on success, or another value if an error occurs. See Error Codes.

## See Also

### Configuring the Timer Source

- [Create](driverkit/iotimerdispatchsource/create.md)
- [init](driverkit/iotimerdispatchsource/init.md)
- [free](driverkit/iotimerdispatchsource/free.md)
