---
title: SetDataAvailableHandler
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/iodataqueuedispatchsource/setdataavailablehandler
---

# SetDataAvailableHandler

Sets the handler block to run when another object adds data to the queue.

## Declaration

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

## Parameters

- `action`: The doc://com.apple.driverkit/documentation/DriverKit/OSAction instance specifying the callback method. The data queue retains this object until you call this method again or call doc://com.apple.driverkit/documentation/DriverKit/IODataQueueDispatchSource/Cancel. This queue executes the action’s handler method on the action’s own dispatch queue.

## Return Value

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

## See Also

### Removing Work from the Queue

- [DataAvailable](driverkit/iodataqueuedispatchsource/dataavailable.md)
- [IsDataAvailable](driverkit/iodataqueuedispatchsource/isdataavailable.md)
- [Peek](driverkit/iodataqueuedispatchsource/peek.md)
- [Dequeue](driverkit/iodataqueuedispatchsource/dequeue.md)
- [DequeueWithCoalesce](driverkit/iodataqueuedispatchsource/dequeuewithcoalesce.md)
- [SendDataServiced](driverkit/iodataqueuedispatchsource/senddataserviced.md)
- [IODataQueueClientDequeueEntryBlock](driverkit/iodataqueueclientdequeueentryblock.md)
