DoWhenIdle.3
上传用户:rrhhcc
上传日期:2015-12-11
资源大小:54129k
文件大小:3k
源码类别:

通讯编程

开发平台:

Visual C++

  1. '"
  2. '" Copyright (c) 1990 The Regents of the University of California.
  3. '" Copyright (c) 1994-1996 Sun Microsystems, Inc.
  4. '"
  5. '" See the file "license.terms" for information on usage and redistribution
  6. '" of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  7. '" 
  8. '" RCS: @(#) $Id: DoWhenIdle.3,v 1.2 1998/09/14 18:39:48 stanton Exp $
  9. '" 
  10. .so man.macros
  11. .TH Tcl_DoWhenIdle 3 7.5 Tcl "Tcl Library Procedures"
  12. .BS
  13. .SH NAME
  14. Tcl_DoWhenIdle, Tcl_CancelIdleCall - invoke a procedure when there are no pending events
  15. .SH SYNOPSIS
  16. .nf
  17. fB#include <tcl.h>fR
  18. .sp
  19. fBTcl_DoWhenIdlefR(fIproc, clientDatafR)
  20. .sp
  21. fBTcl_CancelIdleCallfR(fIproc, clientDatafR)
  22. .SH ARGUMENTS
  23. .AS Tcl_IdleProc clientData
  24. .AP Tcl_IdleProc *proc in
  25. Procedure to invoke.
  26. .AP ClientData clientData in
  27. Arbitrary one-word value to pass to fIprocfR.
  28. .BE
  29. .SH DESCRIPTION
  30. .PP
  31. fBTcl_DoWhenIdlefR arranges for fIprocfR to be invoked
  32. when the application becomes idle.  The application is
  33. considered to be idle when fBTcl_DoOneEventfR has been
  34. called, couldn't find any events to handle, and is about
  35. to go to sleep waiting for an event to occur.  At this
  36. point all pending fBTcl_DoWhenIdlefR handlers are
  37. invoked.  For each call to fBTcl_DoWhenIdlefR there will
  38. be a single call to fIprocfR;  after fIprocfR is
  39. invoked the handler is automatically removed.
  40. fBTcl_DoWhenIdlefR is only usable in programs that
  41. use fBTcl_DoOneEventfR to dispatch events.
  42. .PP
  43. fIProcfR should have arguments and result that match the
  44. type fBTcl_IdleProcfR:
  45. .CS
  46. typedef void Tcl_IdleProc(ClientData fIclientDatafR);
  47. .CE
  48. The fIclientDatafR parameter to fIprocfR is a copy of the fIclientDatafR
  49. argument given to fBTcl_DoWhenIdlefR.  Typically, fIclientDatafR
  50. points to a data structure containing application-specific information about
  51. what fIprocfR should do.
  52. .PP
  53. fBTcl_CancelIdleCallfR
  54. may be used to cancel one or more previous
  55. calls to fBTcl_DoWhenIdlefR:  if there is a fBTcl_DoWhenIdlefR
  56. handler registered for fIprocfR and fIclientDatafR, then it
  57. is removed without invoking it.  If there is more than one
  58. handler on the idle list that refers to fIprocfR and fIclientDatafR,
  59. all of the handlers are removed.  If no existing handlers match
  60. fIprocfR and fIclientDatafR then nothing happens.
  61. .PP
  62. fBTcl_DoWhenIdlefR is most useful in situations where
  63. (a) a piece of work will have to be done but (b) it's
  64. possible that something will happen in the near future
  65. that will change what has to be done or require something
  66. different to be done.  fBTcl_DoWhenIdlefR allows the
  67. actual work to be deferred until all pending events have
  68. been processed.  At this point the exact work to be done
  69. will presumably be known and it can be done exactly once.
  70. .PP
  71. For example, fBTcl_DoWhenIdlefR might be used by an editor
  72. to defer display updates until all pending commands have
  73. been processed.  Without this feature, redundant redisplays
  74. might occur in some situations, such as the processing of
  75. a command file.
  76. .SH BUGS
  77. .PP
  78. At present it is not safe for an idle callback to reschedule itself
  79. continuously.  This will interact badly with certain features of Tk
  80. that attempt to wait for all idle callbacks to complete.  If you would
  81. like for an idle callback to reschedule itself continuously, it is
  82. better to use a timer handler with a zero timeout period.
  83. .SH KEYWORDS
  84. callback, defer, idle callback