- - * - WhiteUnicorn - * - -




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >


Frequently Asked Questions

Alloting CPU time

Question:

How can I change the amount of CPU time that is alotted to my application?

Answer:

The following example demonstrates changing the CPU priority given

an application. Care should be taken when changing the applications

priority, as values that are too high may cause the system to become

unresponsive. For more information, please see the Win32 help

file for the SetThreadPriority() function.



Example:



procedure TForm1.Button1Click(Sender: TObject);

var

  ProcessID : DWORD;

  ProcessHandle : THandle;

  ThreadHandle : THandle;

begin

  ProcessID := GetCurrentProcessID;

  ProcessHandle := OpenProcess(PROCESS_SET_INFORMATION,

                               false,

                               ProcessID);

  SetPriorityClass(ProcessHandle, REALTIME_PRIORITY_CLASS);

  ThreadHandle := GetCurrentThread;

  SetThreadPriority(ThreadHandle, THREAD_PRIORITY_TIME_CRITICAL);

end;




* #WhiteUnicorn/ StartPage/ Documentation/DelphiFAQ >



- - * - Anastasija aka WhiteUnicorn - * - - LJLiveJournal
PFPhotoFile