suspend fun DownloadTask.await(block: () -> Unit = {}): DownloadResult
Awaits for completion of the DownloadTask without blocking current thread. Returns DownloadResult or throws corresponding exception if there is any error occurred.
This suspending function is cancellable. If the Job of the current coroutine is cancelled or completed while this suspending function is waiting, this function immediately resumes with CancellationException.
does something after the DownloadTask start immediately.
Show progress using channel after await, for example:
val task = DownloadTask.Builder().build()
GlobalScope.lunch {
val downloadResult = task.await {
val progressChannel = task.spChannel()
// do progress showing with progressChannel
}
}