for i:=1 to 7500 do; // do nothing
I measure this time,
but I have to give it the highest priority so other tasks will not interrupt
it.
How do I do it?
the idea should me as follow:
- GIVE THE NEXT LOOP THE HIGHEST PRIORITY
- DO THE LOOP
- DISABLE THE HIGHEST PRIORITY TO THE LOOP
Thanks in advance!
Eli
As far as i can remember this can be achieved as follows...
SetPriorityClass(Form1.Handle,HIGH_PRIORITY_CLASS);
--or---
SetPriorityClass(Form1.Handle,REALTIME_PRIORITY_CLASS );
The last one sets the priority to the highest available to windows, but also
means that all processes will sease thus causing a lot of processing when
the loop has finished.
As far as i know there is not function in the windows api for canceling a
priority level so you would simply call the function again as follows
SetPriorityClass(Form1.Handle,NORMAL_PRIORITY_CLASS );
"Eli" <el...@roseman.co.il> wrote in message news:3beaa644_1@dnews...
Move the loop to a thread and disable input to your main application (say
show a form modally that says processing) till the thread is finished.
TThread has a Priority Property. This would allow you to give the thread a
high priority to do the processing and allow you to give the user a way to
cancel (Say a cancel button on the processing form).
Hope this helps.
Thanks
Wayne
"Scott" <Sc...@Input.ie> wrote in message news:3beaab29$1_2@dnews...
begin
PriorityClass := GetPriorityClass(GetCurrentProcess);
Priority := GetThreadPriority(GetCurrentThread);
SetPriorityClass(GetCurrentProcess, REALTIME_PRIORITY_CLASS);
SetThreadPriority(GetCurrentThread, THREAD_PRIORITY_TIME_CRITICAL);
your loop
SetThreadPriority(GetCurrentThread, Priority);
SetPriorityClass(GetCurrentProcess, PriorityClass);
end;
Bruno Lovatti
Hortifruti - Tecnologia da Informação