             guard let httpTask = tasks.first(where: { $0.task === dataTask }) else { return }
 
             httpTask.data.append(data)
-            httpTask.download.bytes = Int64(httpTask.data.count)
-            httpTask.download.callback?(httpTask.download.bytes, httpTask.download.totalBytes)
+            let bytes = Int64(httpTask.data.count)
+            httpTask.download.bytes = bytes
+            let total = httpTask.download.totalBytes
+            responseQueue.async {
+                httpTask.download.callback?(bytes, total)
+            }
         }
 
         func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) {

            let total = totalBytesExpectedToSend != NSURLSessionTransferSizeUnknown ? totalBytesExpectedToSend : nil
            httpTask.upload.bytes = totalBytesSent
            httpTask.upload.totalBytes = total
            httpTask.upload.callback?(httpTask.upload.bytes, httpTask.upload.totalBytes)
        }

        func urlSession(

        self.responseQueue = responseQueue

        let delegateQueue = OperationQueue()
        delegateQueue.qualityOfService = .userInitiated
        delegateQueue.maxConcurrentOperationCount = 1
        delegateObject = Delegate(queue: delegateQueue, responseQueue: responseQueue)
        session = URLSession(configuration: configuration, delegate: delegateObject, delegateQueue: delegateQueue)
    }

