Background sleep, enters the event loop for "delay" milliseconds
proc bgsleep {delay} { set final_time [expr ([clock seconds] * 1.0) + (($delay * 1.0) / 1000.0)] set activation_var [join [list BGSLEEP WAIT FOR $final_time [expr rand()]] _] global $activation_var after $delay [list set $activation_var 1] vwait $activation_var }