I was going to suggest the PPL (Parallel Programming Library), or OmniThreadLibrary, or... but then I read you are using Delphi 7. Back then - plain old TThread? Upgrade sixteen years' worth of technology and you'll get a lot more, and access to a lot more :)
I found some sample as below after google search. However still do not know how to pass multiple parameters to the Thread method. Does anyone have a solution?
procedure TForm1.Button4Click(Sender: TObject); begin FAsyncCall := AsyncCall(ThreadProcParam, 100); end;
procedure TForm1.ThreadProcParam(count: integer); var x: integer;
procedure LocalReportProgress(param: integer); begin ProgressBar1.Position := param; end;
begin for x := 1 to count do begin LocalAsyncVclCall(@LocalReportProgress, x); sleep(50); end; end;
I was going to suggest the PPL (Parallel Programming Library), or OmniThreadLibrary, or... but then I read you are using Delphi 7. Back then - plain old TThread? Upgrade sixteen years' worth of technology and you'll get a lot more, and access to a lot more :)
ReplyDeleteIn order to make a good recommendation we'd need to know what your goals and constraints are.
ReplyDeleteI found some sample as below after google search. However still do not know how to pass multiple parameters to the Thread method. Does anyone have a solution?
ReplyDeleteprocedure TForm1.Button4Click(Sender: TObject);
begin
FAsyncCall := AsyncCall(ThreadProcParam, 100);
end;
procedure TForm1.ThreadProcParam(count: integer);
var
x: integer;
procedure LocalReportProgress(param: integer);
begin
ProgressBar1.Position := param;
end;
begin
for x := 1 to count do
begin
LocalAsyncVclCall(@LocalReportProgress, x);
sleep(50);
end;
end;