From: ccrause@ing.sun.ac.za (Christo Crause)
Subject: Re: Working when processor idle
Date: 02 Apr 1999 00:00:00 GMT
Message-ID: <7e35f8$efn$1@news.adamastor.ac.za>
References: <7e0lc7$3io$1@news5.svr.pol.co.uk> <7e20k6$pg0$1@news.adamastor.ac.za>
Content-Type: Text/Plain; charset=US-ASCII
Organization: Dept. Chem. Eng.
Mime-Version: 1.0
Newsgroups: alt.comp.lang.borland-delphi
In article <7e20k6$pg0$1@news.adamastor.ac.za>, ccrause@ing.sun.ac.za says...
>
>In article <7e0lc7$3io$1@news5.svr.pol.co.uk>,
>rawlyn@nospam.chplayers.freeserve.co.uk says...
>>
>>Is it at all possible to have my program only calculate when the processor
>>is idle?
>I suggest you change the programs thread priority to IDLE_PRIORITY_CLASS. This
>is the lowest thread priority, and according to the win32 help file it only
>gets processor time when the processor is idle. The easiest way to set your
>programs thread priority is by starting it from another program with
>CreateProcess. The thread priority is set in the dwCreationFlags parameter.
What was I thinking! It is very easy for a thread to adjust its priority:
var hProcess, hThread : THandle;
success : boolean;
begin
hProcess := GetCurrentProcess;
success := SetPriorityClass(hProcess, IDLE_PRIORITY_CLASS);
hThread := GetCurrentThread;
success := SetThreadPriority(hThread, THREAD_PRIORITY_IDLE);
if not success then messagebeep(0);
end
--
Christo Crause
Thermal Separations Research
University of Stellenbosch
South Africa