Re: Escape, read events & loops by Jack
Jack
Fri Jan 12 08:50:38 CST 2007
No, other processes always run no matter what you do in VFP.
DOEVENTS runs the VFP event loop, which causes mouse and keyboard
events in your VFP program to fire.
If you use DOEVENTS you have to be very careful to prevent any events
that would be incompatible with the batch process that is running
(like starting the same batch process up again, deleting or modifying
data that the batch process is using, etc.). Also, you can't call
DOEVENTS from code that runs because of another DOEVENTS command (e.g.
while one batch process is running that calls DOEVENTS you can't allow
another batch process to start and also call DOEVENTS).
On Fri, 12 Jan 2007 09:25:05 -0500, "Lew Schwartz"
<lschwartz@sionline.com> wrote:
>I thought that doevents only enabled interruption by desktop processes
>outside my app. I'll check this out. Thanks.
>-Lew
>"Olaf Doschke" <b2xhZi5kb3NjaGtlQHNldG1pY3MuZGU.strconv.14@t-online.de>
>wrote in message news:eo7f3j$vo$01$1@news.t-online.com...
>> >If some of the command buttons have cmd.Cancel set to .T., then it fires
>> >its click event if the user presses ESC.
>>
>> Yes, so that's the main point, but this click()
>> won't run if there is no doevents in the batch
>> processing loop. Still better than inkey().
>>
>> So roughly it's:
>>
>> cmdStart.Click()
>> Thisform.lStopprocessing = .F.
>> Thisform.Batchprocess()
>>
>> cmdCancel.Cancel=.T.
>> cmdCancel.Click()
>> Thisform.lStopprocessing = .T.
>>
>> Batchprocess
>> do while NOT thisform.lStopprocessing
>> ....
>> doevents
>> ...
>> doevents
>> ...
>> doevents force
>> enddo
>>
>> ESC then can stop the process.
>>
>> Bye, Olaf.
>