Hi Fabio,
Thank for confirming that this is a bug of INKEY(1). I solved the problem by replacing it with the SLEEP() API function.
This is an application to monitor the content change of a special shared folder. Every second, it writes a summary of the content change into a new record of a DBF (also displayed on screen using "?") for future analysis. There is neither any form nor control on the screen.
I use a loop rather than the Timer because it is simpler and easier to stepping through to debug.
Very often, the application is run unattendedly as a scheduled task. Therefore "ON SHUTDOWN ..." is necessary so that the running task can be stopped by choosing the STOP option of the Windows Scheduler menu.
KM
>>Can anybody tell me what's wrong with this code? Or, can anybody suggest a workaround?
>>
>>
>>x=.T.
>>On Shutdown x=.F.
>>
>>o=Createobject('MyClass')
>>
>>Define Class MyClass As Custom
>> Function Init
>> Do While x
>> ? Datetime()
>> =Inkey(1)
>> EndDo
>>EndDefine
>>
>>
>>In either development time or run time, when we try to close the application, VFP crashes!
>>
>>TIA
>
>A bug.
>
>Crash into VFP8 and VFP9b
>
>Preconditions:
>- On Shutdown is not empty
>- VFP wait for a keypress with INKEY() or CHRSAW()
>-
_VFP
process a WM_CLOSE message
>
>A more simple repro:
>
>DECLARE SHORT PostMessage IN user32;
> INTEGER hWnd,;
> INTEGER Msg,;
> INTEGER wParam,;
> INTEGER lParam
>
>On Shutdown KEYBOARD '{SPACEBAR}'
>
>=PostMessage(_VFP.hWnd,16,0,0)
>=CHRSAW(1)
>
>
>WorkAround:
>use READ EVENTS
>Fabio