Claude
Tue Oct 24 09:11:10 CDT 2006
Here are the APIs to achieve a more precise processor usage(Use with care!):
DECLARE INTEGER GetCurrentThread ;
IN WIN32API
DECLARE INTEGER GetThreadPriority ;
IN WIN32API ;
INTEGER tnThreadHandle
DECLARE INTEGER SetThreadPriority ;
IN WIN32API ;
INTEGER tnThreadHandle,;
INTEGER tnPriority
FUNCTION GetCurrentThread
************************************************************************
* GetCurrentThread
*********************************
*** Function: Returns handle to the current Process/Thread
*** Return: Process Handle or 0
************************************************************************
RETURN GetCurrentThread()
ENDFUNC
* GetProcess
************************************************************************
* GetThreadPriority
*********************************
*** Function: Gets the current Priority setting of the thread.
*** Use to save and reset priority when bumping it up.
*** Pass: tnThreadHandle
************************************************************************
FUNCTION GetThreadPriority
LPARAMETER tnThreadHandle
RETURN GetThreadPriority(tnThreadHandle)
ENDFUNC
* GetThreadPriority
FUNCTION SetThreadPriority
************************************************************************
* SetThreadPriority
*********************************
*** Function: Sets a thread process priority. Can dramatically
*** increase performance of a task.
*** Pass: tnThreadHandle
*** tnPriority 0 - Normal
*** 1 - Above Normal
*** 2 - Highest Priority
*** 15 - Time Critical
*** 31 - Real Time
************************************************************************
LPARAMETER tnThreadHandle,tnPriority
RETURN SetThreadPriority(tnThreadHandle,tnPriority)
ENDFUNC
* GetThreadPriority
"Claude Fox" <cfuchs@activevfp.com> wrote in message
news:uynQmL39GHA.1200@TK2MSFTNGP02.phx.gbl...
> In an appropriate place (like in a processor intensive loop), put the api
> call to sleep as in:
> DECLARE Sleep IN WIN32API INTEGER
> FOR lncount = 1 TO READSIZE
> lcInput=m.lcInput+ CHR(laBlob1(lncount))
> Sleep(0) && 0 allows the processor to do other things
> ENDFOR
> If you suspect memory might also be a factor, try:
> SYS(3050, 1, VAL(SYS (3050, 1, 0)) / 3) && uses 1/3 available mem
>
> Claude Fox
> ActiveVFP - Open Source Web Development with VFP
>
http://www.activevfp.com
> "Brian McKillop" <brian.nospamforme@mckillopassociates.com.au> wrote in
> message news:kgh%g.52074$rP1.49827@news-server.bigpond.net.au...
>>I have a VFP7 app that does some pretty major number crunching while
>>generating particular reports.
>>
>> My client has asked that I limit CPU usage to a particular value (say
>> 70%) at specific places within the app.
>>
>> How can I do that within VFP?
>>
>> Thanks,
>>
>> Brian
>>
>
>