Please enable JavaScript to view this site.

R:BASE 11 Help

Navigation: Reference Index > Multi-User Guide > Increasing Application Performance

Displaying Messages in Long Tasks

Scroll Prev Top Next More

Command Routines

It is helpful to show a progress message when performing long running tasks. When processing a time-consuming routine, there are ways to let the user know the status of the process using the PAUSE 3 with GAUGE options as well as the use of PROCESSMESSAGE command, which processes messages that are currently in the windows message queue. The PROCESSMESSAGE can help in the GUI part to avoid the "Not responding" behavior in Windows operating systems. A common use of PROCESSMESSAGE is in long WHILE loops.

 

PROCESSMESSAGE may be called in each loop iteration to give the GUI time to process the pending Windows messages. For a loop that only does data processing, PROCESSMESSAGE can also be used. It is advised to disable GUI update settings like UINOTIF before entering the loop with PROCESSMESSAGE, to counter some side-effects of PROCESSMESSAGE.

 

If is also important to not overuse PROCESSMESSAGE. Use the command only in places where it is necessary for the GUI to "breath" during a long running task.

 

PROCESSMESSAGE can be called after every iteration in the WHILE loop cycle. The following example demonstrates where to best place the PROCESSMESSAGE command.

 

When using the PAUSE, the NO_FOCUS option can also be used so the dialog will not be focused when displayed, which can be used to possibly prevent an interruption in the focus transition in an active form.

 

PAUSE 3 USING ' Calculating ... Please Stand By ...' +

CAPTION ' PAUSE Gauge with PROCESSMESSAGE' ICON APP +

OPTION GAUGE_VISIBLE ON +

|GAUGE_COLOR GREEN +

|GAUGE_INTERVAL 10 +

|MESSAGE_FONT_NAME Verdana +

|MESSAGE_FONT_SIZE 10 +

|MESSAGE_FONT_COLOR BLUE +

|NO_FOCUS

SET VAR vcounter INTEGER = 1

WHILE vcounter < 2500000 THEN

 SET VAR vcounter = (.vcounter + 1)

 PROCESSMESSAGE

ENDWHILE

CLEAR VARIABLE vcounter

CLS

 

Forms

Windows will flag a form as "not-responsive" if it is not able to process messages in the queue after some time. It is not advisable to use PAUSE as progress indicator for long running form tasks. A progress indicator "within" the form represented as a panel is preferred. A panel at the center of the form can be displayed, updated after every step in the routine, and then hidden after the routine completes. The logic below will assist in avoiding the "Not responding" Windows behavior in forms.

 

PROPERTY SaveButton ENABLED FALSE

PROPERTY ProgressPanel VISIBLE TRUE

--Step #1

PROPERTY ProgressPanel CAPTION 'Working on stuff #1...'

PROCESSMESSAGE

...

...

...

--Step #2

PROPERTY ProgressPanel CAPTION 'Working on stuff #2...'

PROCESSMESSAGE

...

WHILE ...

 ...

     ...

     --if a single iteration is quick enough, PROCESSMESSAGE can be called after a few iterations

     PROCESSMESSAGE

ENDWHILE

...

--Step #3

PROPERTY ProgressPanel CAPTION 'Working on stuff #3...'

PROCESSMESSAGE

...

...

...

PROPERTY ProgressPanel VISIBLE FALSE

PROPERTY SaveButton ENABLED TRUE