asDeferred

fun <T> Task<T>.asDeferred(): Deferred<T>

Converts this task to an instance of Deferred. If task is cancelled then resulting deferred will be cancelled as well.