isActive

Returns true when the current Job is still active (has not completed and was not cancelled yet).

Check this property in long-running computation loops to support cancellation:

while (isActive) {
// do some computation
}

This property is a shortcut for coroutineContext.isActive in the scope when CoroutineScope is available. See coroutineContext, isActive and Job.isActive.


Returns true when the Job of the coroutine in this context is still active (has not completed and was not cancelled yet) or the context does not have a Job in it.

Check this property in long-running computation loops to support cancellation when CoroutineScope.isActive is not available:

while (coroutineContext.isActive) {
// do some computation
}

The coroutineContext.isActive expression is a shortcut for get(Job)?.isActive ?: true. See Job.isActive.