Posted to tcl by kbk at Tue Feb 23 22:07:17 GMT 2021view raw
- namespace eval n {
- proc schedule {x} {
- after 1000 [namespace code [list handleEvent $x]]
- }
- proc handleEvent {x} {
- variable done
- set done "handled event with data \"$x\""
- }
- proc awaitEvent {} {
- variable done
- vwait [namespace current]::done
- return $done
- }
- }
- n::schedule "hello, world"
- puts [n::awaitEvent]