Set priority of a remote procedure call?

Hello all,

I have written a ROSDK service in Delphi that answers queries. In order to do that, it has to evaluate a colossal dataset which makes it very CPU- and disk-intensive.

I would like to be able to lower the thread priority of this task because it disrupts some very time-critical data acquisition tasks running on the same server. Is that possible?

Regards,
Arthur

Hello,
You can create a separate thread and set any priority to it.

Starting a worker thread would require me to do a pretty big code change: the way the code is now, any exceptions happening in the remote routine are propagated back to the caller. If I move my code to a separate worker thread that would no longer work.

Can’t I just do a simple SetPriorityClass (hInstance,BELOW_NORMAL_PRIORITY_CLASS) in the DPR, and give all threads a somewhat lower priority that way?

Hello,
You can call SetThreadPriority function at the beginning of your remote method:

//your remote method
begin
SetThreadPriority(GetCurrentThreadId(), THREAD_PRIORITY_BELOW_NORMAL);
//any code
end;