Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Add file an .EXE after it is built?
Message
 
 
To
16/04/2019 19:15:26
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01668100
Message ID:
01668140
Views:
28
>>>If you're actively waiting, you can do this:
>>>
DECLARE Sleep IN WIN32API INTEGER nMilliseconds
>>>
>>>DO WHILE whatever
>>>    DOEVENTS FORCE
>>>    Sleep(100)   && Sleep for 1/10th of a second
>>>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.

Thank you. I will "play" with these options.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform