summaryrefslogtreecommitdiffstats
path: root/doc/after.n
diff options
context:
space:
mode:
authordkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:35:37 (GMT)
committerdkf <donal.k.fellows@manchester.ac.uk>2004-10-27 09:35:37 (GMT)
commit7ea5d4dbe8b82a86701cec95132a8a9557a5f105 (patch)
tree2f3f979845a50074bb8e2a0687cd98cb14ae6c26 /doc/after.n
parenta50314f88b2a6af554553927c9c0e590c0acf7dc (diff)
downloadtcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.zip
tcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.tar.gz
tcl-7ea5d4dbe8b82a86701cec95132a8a9557a5f105.tar.bz2
Backport many doc fixes
Diffstat (limited to 'doc/after.n')
-rw-r--r--doc/after.n39
1 files changed, 38 insertions, 1 deletions
diff --git a/doc/after.n b/doc/after.n
index 7e9a767..4db2815 100644
--- a/doc/after.n
+++ b/doc/after.n
@@ -5,7 +5,7 @@
'\" See the file "license.terms" for information on usage and redistribution
'\" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
'\"
-'\" RCS: @(#) $Id: after.n,v 1.3 2000/09/07 14:27:45 poenitz Exp $
+'\" RCS: @(#) $Id: after.n,v 1.3.18.1 2004/10/27 09:35:38 dkf Exp $
'\"
.so man.macros
.TH after n 7.5 Tcl "Tcl Built-In Commands"
@@ -102,6 +102,43 @@ In applications that are not normally event-driven, such as
\fBtclsh\fR, the event loop can be entered with the \fBvwait\fR
and \fBupdate\fR commands.
+.SH "EXAMPLES"
+This defines a command to make Tcl do nothing at all for \fIN\fR
+seconds:
+
+.CS
+proc sleep {N} {
+ \fBafter\fR [expr {int($N * 1000)}]
+}
+.CE
+
+This arranges for the command \fIwake_up\fR to be run in eight hours
+(providing the event loop is active at that time):
+
+.CS
+\fBafter\fR [expr {1000 * 60 * 60 * 8}] wake_up
+.CE
+
+The following command can be used to do long-running calculations (as
+represented here by \fI::my_calc::one_step\fR, which is assumed to
+return a boolean indicating whether another step should be performed)
+in a step-by-step fashion, though the calculation itself needs to be
+arranged so it can work step-wise. This technique is extra careful to
+ensure that the event loop is not starved by the rescheduling of
+processing steps (arranging for the next step to be done using an
+already-triggered timer event only when the event queue has been
+drained) and is useful when you want to ensure that a Tk GUI remains
+responsive during a slow task.
+
+.CS
+proc doOneStep {} {
+ if {[::my_calc::one_step]} {
+ \fBafter\fR idle [list \fBafter\fR 0 doOneStep]
+ }
+}
+doOneStep
+.CE
+
.SH "SEE ALSO"
bgerror(n), concat(n), update(n), vwait(n)