---
title: SetEnableWithCompletion
framework: driverkit
role: symbol
role_heading: Instance Method
path: driverkit/iotimerdispatchsource/setenablewithcompletion
---

# SetEnableWithCompletion

Enables or disables the timer.

## Declaration

```occ
virtual kern_return_t SetEnableWithCompletion(bool enable, IODispatchSourceCancelHandler handler);
```

## Parameters

- `enable`: A Boolean value that indicates whether to enable or disable the timer. Specify doc://com.apple.documentation/documentation/Swift/true to enable the timer or doc://com.apple.documentation/documentation/Swift/false to disable it.
- `handler`: An optional block to execute after any pending handlers of a newly disabled timer finish executing.

## Return Value

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

## See Also

### Starting and Stopping the Timer Source

- [Cancel](driverkit/iotimerdispatchsource/cancel.md)
