>>If you're actively waiting, you can do this:
>>
DECLARE Sleep IN WIN32API INTEGER nMilliseconds
>>
>>DO WHILE whatever
>> DOEVENTS FORCE
>> Sleep(100)
>>ENDDO
>>
>>That Sleep() code will make your app polite, so it won't be in a spin-loop consuming 100% of the CPU core, making your system run cooler, use less power, and is more polite to other apps desiring to use CPU resources.
>
>I did a search through my app code and found that wwapi.prg has this function, Sleep. But what I find interesting that there is a function Sleep and then there is a API function sleep. Here is the code:
>
>FUNCTION Sleep(lnMilliSecs)
>
>lnMillisecs=IIF(type("lnMillisecs")="N",lnMillisecs,0)
>
>DECLARE Sleep ;
> IN WIN32API ;
> INTEGER nMillisecs
>
>=Sleep(lnMilliSecs)
>ENDFUNC
>
>
>So, my question, if I call in my other routine Sleep(nSec) without DECLARE sleep, will it call the function Sleep() in the wwApi.prg? Or should I simply declare the Sleep and not rely on the wwApi.prg? (In case you don't use it, wwApi.prg is the PRG that comes with the West Wind product.
I've never used West Wind products, but knowing it's a Rick Strahl product it's likely safe and effective to use. It will call the one declared in wwApi.prg if it's not declared elsewhere.
I would've declared it this way:
FUNCTION Sleep
LPARAMETERS lnMilliSecs
DECLARE Sleep IN WIN32API AS WindowsSleep INTEGER
WindowsSleep(IIF(TYPE("lnMillisecs") = "N", lnMillisecs, 0))
ENDFUNC
His function name use may be incredibly clever, in that the first time it calls VFP's function Sleep, and thereafter it calls Windows' function Sleep. Quite a thing if true.