WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Dialog Editor version 6.X
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

High CPU Usage and Dialogs


Question:

I am trying to figure out why I get high CPU usage when using the following script. First, load Performance within Task Manager and then click Go on the dialog. You will notice the CPU Usage jumps to 100% for time the Timedelay function runs. Any clues as to how to resolve this without having to use the Dialogs timer function?
#DefineSubRoutine timer(time)
TimeDelay(time)
Return(-1)
#EndSubRoutine

#DefineSubRoutine MyDialogProc(DialogHandle, EventCode, ControlNum, Res4, Res5)

Switch(EventCode)

Case 0 ; Initialize

DialogProcOptions(DialogHandle, 2, 1);Monitor buttons

Case 2 ; Button Pushed
Switch(ControlNum)
Case 3 ;go Button
timer(10)
Break
Case 2 ;Exit
Exit
Break
EndSwitch ;End ControlNum
EndSwitch ; End EventID
Return -2
#EndSubRoutine

MyDialogFormat=`WWWDLGED,6.1`

MyDialogCaption=`WIL Dialog 1`
MyDialogX=002
MyDialogY=061
MyDialogWidth=406
MyDialogHeight=223
MyDialogNumControls=003
MyDialogProcedure=`MyDialogProc`
MyDialogFont=`DEFAULT`
MyDialogTextColor=`DEFAULT`
MyDialogBackground=`DEFAULT,DEFAULT`
MyDialogConfig=0

MyDialog001=`111,205,036,012,PUSHBUTTON,DEFAULT,"OK",1,1,32,DEFAULT,DEFAULT,DEFAULT`
MyDialog002=`259,205,036,012,PUSHBUTTON,DEFAULT,"Exit",0,2,DEFAULT,DEFAULT,DEFAULT,DEFAULT`
MyDialog003=`191,125,036,012,PUSHBUTTON,DEFAULT,"Go",2,3,DEFAULT,DEFAULT,DEFAULT,DEFAULT`

ButtonPushed=Dialog("MyDialog",1)

Answer:

The problem is the long TimeDelay in your callback procedure. You will probably want to displble the Dialog before the long delay then reenable after the delay:

DPO_DISABLESTATE = 1000
DialogProcOptions(MyProcDlgHandle,DPO_DISABLESTATE,2) ;disable dialog
TimeDelay(1)
DialogProcOptions(MyProcDlgHandle,DPO_DISABLESTATE,0) ;enable dialog


Article ID:   W16921
File Created: 2007:07:03:14:27:04
Last Updated: 2007:07:03:14:27:04