Tcl Source Code

Artifact [34e29c3c57]
Login

Artifact 34e29c3c57164eff345a66bfb18c4f3376e7cd77:

Attachment "after.diff" to ticket [938820ffff] added by davidw 2004-04-21 02:58:11.
Index: after.n
===================================================================
RCS file: /cvsroot/tcl/tcl/doc/after.n,v
retrieving revision 1.3
diff -u -r1.3 after.n
--- after.n	7 Sep 2000 14:27:45 -0000	1.3
+++ after.n	20 Apr 2004 19:36:31 -0000
@@ -102,6 +102,37 @@
 \fBtclsh\fR, the event loop can be entered with the \fBvwait\fR
 and \fBupdate\fR commands.
 
+.SH "EXAMPLES"
+
+Command to sleep for N seconds:
+
+.CS
+proc sleep {N} {
+    after [expr {$N * 1000}]
+}
+.CE
+
+Run "wakeup" command after 8 hours:
+
+.CS
+after [expr {1000 * 60 * 60 * 8}] wakeup
+.CE
+
+Command that will call itself to do one step of a long-running
+calculation.  This is a useful technique to keep a Tk GUI responsive
+while performing a slow task, for instance.
+
+.CS
+proc doOneStep {} {
+    if { [::my_calc::one_step] } {
+        after idle [list after 0 doOneStep]
+    }
+    return
+}
+my_calc::start
+doOneStep
+.CE
+
 .SH "SEE ALSO"
 bgerror(n), concat(n), update(n), vwait(n)