public class NonCancellable implements Job
A non-cancelable job that is always Job.isActive
. It is designed for BuildersKt.withContext
function
to prevent cancellation of code blocks that need to be executed without cancellation.
Use it like this:
withContext(NonCancellable) {
// this code will not be cancelled
}
Job.isActive
,
BuildersKt.withContext
Job.DefaultImpls, Job.Key
Modifier and Type | Field and Description |
---|---|
static NonCancellable |
INSTANCE
A non-cancelable job that is always
Job.isActive . It is designed for BuildersKt.withContext function
to prevent cancellation of code blocks that need to be executed without cancellation. |
cancel, getChildren, getOnJoin, invokeOnCompletion, isActive, isCancelled, isCompleted, join, start
public static NonCancellable INSTANCE
A non-cancelable job that is always Job.isActive
. It is designed for BuildersKt.withContext
function
to prevent cancellation of code blocks that need to be executed without cancellation.
Use it like this:
withContext(NonCancellable) {
// this code will not be cancelled
}
Job.isActive
,
BuildersKt.withContext