德尔福:我如何改变ITask的优先级?

时间:2017-10-14 15:14:19

标签: multithreading delphi task

我有一些在后台工作的低优先级任务,我不关心它们的执行速度,但有时候必须尽快执行一项任务。我是怎么做到的?

for k:=1 to 100 do begin 
  Orders[k] := TTask.Create(NewOrder,NewOrder.DoTheJob);
  Orders[k].Start;
end;
......
FastOrder := TTask.Create(NewOrder,NewOrder.DoTheJob);
FastOrder.Start; // I want this task to be executed ASAP, 
    //but actually it waits unpredictable time until there is a free slot
    // in task's queue or so. 
    //It can delay up to 1 minute depending on how many reqular tasks i have

1 个答案:

答案 0 :(得分:-2)

使用TThread.createAnonymousThread代替TTask