Skip to content

Modern Chan WithCancel

Paul Squires edited this page Oct 19, 2026 · 5 revisions

Home › Goroutines and Channels › Goroutines and Channels › WithCancel

WithCancel

Returns a child context that you cancel yourself.

Syntax

WithCancel( parent )

Notes

  • a cancellable child

Examples

#import "std/tasks"
using tasks

dim root as Context
dim ctx as CancelContext = WithCancel( root )

print ctx.IsCancelled( )     '' false

ctx.Cancel( )                '' the caller decides when
print ctx.IsCancelled( )     '' true
print ctx.Err( )             '' cancelled

'' Cancelling a parent cancels its children too, so one Cancel( ) at the
'' top shuts down a whole tree of workers

Library: Goroutines and Channels
Category: Goroutines and Channels
Documented under: Context

Clone this wiki locally