Eric Bennett wrote:
> On Fri, 15 Dec 2000, Robert Sherman wrote:
>
>> any idea as to why in the script below, in sub Button2_Click,
>> TextField1 does not change to "Processing..." prior to running
>> the process_file sub? A similar call in the process_file sub
>> changes the field to "Done!" when it finishes, and that call
>> works fine...
>
> The Text method is queueing a message to TestField1 to change,
> but that message cannot be acted upon until the current *_Click
> event exits.
>
> What ends up happening is that process_file runs, then
> afterward the text changes twice quickly as the messages are
> processed.
correct, and very well explained! thanks Eric ;-)
> How to fix it? I don't have enough experience with Win32::GUI.
I can help here.
in the process_file sub, put a call to DoEvents() inside the
loop. this will ensure that all queued messages are processed
before going on with the loop:
foreach $line (<INFILE>) {
$Window->DoEvents();
# body of the loop...
}
this will, of course, make your loop run slightly slower (almost
irrelevant if there is no activity on the window). but there is
the advantage (other than having the Textfield saying
"Processing...") of being able to stop the loop in the middle
by killing the window, or with a 'dedicated' stopbutton, for
example.
cheers,
Aldo
__END__
$_=q,just perl,,s, , another ,,s,$, hacker,,print;