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.

WaitForKey Inside a Dialog Callback


Question:

I cleaned up a script and added a callback to a dialog (instead of using lots of 'If buttonpushed' options). One of the buttons - named HIDE - initiates WaitForKey. In the prior script when the HIDE button was pushed, the script would then wait for the END key to be pressed, and when it was the dialog would be reinitialized (since the dialog was naturally disposed of).

Since a callback does not dispose of the dialog (that's the whole idea), the HIDE button now first initiates WinHide to hide the dialog window, WaitForKey (END) and when the END key is pressed it does a WinActivate to bring the dialog window back up.

Everything works as expected in both scripts. However, the problem now is that the callback script pushes CPU usage way up while it sits and waits for the END key to be pressed. It happens in either debug mode or when compiled.

Here is a short sample of the problem. The first WaitForKey is outside the UDS and behaves as expected. Once inside the UDS is when the problem happens. Can you explain what is going on? Any way out of it?

Windows XP, SP1
Winbatch 2005A

Answer:

Thats just the way it kinda works.

You might get (maybe) better results if you disable the dialog with DialogProcOptions 1000 before the wait for key then enable the dialog afterwards.

Still its a naughty thing to do. DialogCallbacks are supposed to return as quickly as possible, the penalty being is that they burn hordes of cpu time.

User Reply:

That seems to have done the trick, Marty. Processer returns to zero when waiting inside the UDS. Whew!! I spent a ton of time on the script conversion to a callback and felt quite trapped by the problem. I'll watch it the next couple of days to see that it continues to run stable. Using the DialogProcOptions to re-enable the dialog adds a teeny bit of delay, but no one would ever really know the difference. Thanks so much for the suggestion!
Article ID:   W16925
File Created: 2007:07:03:14:27:06
Last Updated: 2007:07:03:14:27:06