Answer the question
In order to leave comments, you need to log in
How to work with tasks correctly?
Tell me how to correctly transfer parameters to the task?
Function Test(Const Xn, Wn: Array of Real): Real;
Var
Sum: Real; // взвешенная сумма.
i: Integer; // счетчик.
tasks: array of itask;
begin
Sum := 0;
SetLength(tasks, High(Xn));
For i := 0 To High(Xn) Do
begin
tasks[i] := TTask.Create(
procedure()
begin
Sum := Sum + Xn[i] * Wn[i]; // подсчет взвешенной суммы.
end);
for I := 0 to High(tasks) do
tasks[i].Start;
TTask.WaitForAll(tasks);
end;
end;
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question