doWindowEvents

doWindowEvents(waitTime: Integer);

The doWindowEvents method of the Application class processes all queued messages for the application until one of:

When the doWindowEvents method has processed all pending Windows events, it then waits and processes any further Windows events that arrive until the specified time from when the method was initiated has expired.

You can call the doWindowEvents method from any type of application (for example, from a non-GUI application to allow the processing of timers and notifications) or from a server method.

For example, the doWindowEvents method allows:

Do not use the doWindowEvents method in the following situations.

Call the doWindowEvents method from a server method to process server notifications and timers.

Indiscriminate use of this method can cause unwanted side effects. For example, it can change the order of Windows event processing and can allow users to click on other controls, menus, or forms that could have an impact on the current process.

It can also cause recursive loops. For example, if a keyDown event calls a doWindowEvents method and the user is holding down the key, that method will invoke another keyDown event, and so on. JADE handles this situation by discarding messages for a specific window if there are already five such messages in the call stack.

Use of app.doWindowEvents can be dangerous because it can result in recursive calls and can mean events are processed out of order. It is also an expensive operation under thin client mode. Its use should be very restricted and only when the consequences are clearly understood.

The following example shows the use of the doWindowEvents method.

queryUnload(cancel: Integer io; reason: Integer) updating;
begin
    self.endTimer(101);               // ticker tape timer
    app.doWindowEvents(0);
    if self.bTotalWorth.value then
        self.endTimer(Graph_Timer);
        app.doWindowEvents(0);
    endif;
end;

See also the Process class sleep method. For more details, see "Windows Events and JADE Events", in Chapter 2.