advr.hlp (Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DOEVENTS Function Details
  Summary  Details  Example                Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 DOEVENTS()
 
 Usage Notes
   ■ Form events are not processed within standard event-handling procedures.
     Some procedures may contain code which takes several seconds to run.
     Therefore, if you want to respond to form events while these procedures
     are running, you must intersperse calls to DOEVENTS in the procedure.
     For example:
     • In response to a Click event, you may want to sort a list containing
       thousands of items.
     • While the list is being sorted, you display a message box with a
       Cancel button that asks the user to wait until the sort has been
       completed.
     • For the Cancel button to work, you must place a call to DOEVENTS
       in the sorting routine. This allows the Click event for the Cancel
       button to be processed during the sort. Without DOEVENTS, the Click
       event for the Cancel button cannot be processed until the sort is
       completed.
 
   ■ Be careful using DOEVENTS. If you use a DOEVENTS function in a Click
     event procedure, you can receive a second click (during DOEVENTS
     processing) before control returns from processing the first Click
     event. This type of re-entrancy error could occur in the sort example
     above if:
     • The user is allowed to click the button that starts the sort routine
       while the sort is being performed.
     • The second Click procedure attempts to open the list file, which has
       already been opened by the first Click procedure.
 
   ■ If the startup module in your program is a form module, form events
     processing begins automatically. If the start-up module in your program
     is not a form module, you must call DOEVENTS to begin form event
     handling. When the first form in the program is made visible, use
     DOEVENTS in a continual loop to begin processing form events. For
     example:
 
         Form1.SHOW
         WHILE DOEVENTS():WEND
 
   ■ DOEVENTS causes form events to be processed until there are no forms
     loaded.
 
   ■ Be aware of global variables when using DOEVENTS. It is possible for an
     event procedure that is called during DOEVENTS processing to reset the
     value of a global variable upon which the original procedure depends.