         }
     }
 
+    /// Pauses the task, maintaining the repeat count and same closure.
     public func stop() {
         guard isActive else { return }
         isActive = false

    private func executeOp() {
        if let count = repeatCount, currentCount >= count {
            isComplete = true
            return
        }
        guard isActive else { return }

public class RepeatedTask {
    let operation: Block
    let timeBetweenOps: TimeInterval

    /// nil repeatCount means infinite
    let repeatCount: Int?
    let queue: DispatchQueue

    private var currentCount: Int = 0
    public private(set) var isComplete = false
    public private(set) var isActive = false

    public init(repeatCount: Int? = nil, timeBetweenOps: TimeInterval = 0, on queue: DispatchQueue = DispatchQueue.main, operation: @escaping Block) {
        self.operation = operation
