Casady
asked on
Migrating from Indy 9 to 10 with Delphi, TIdSchedulerOfThreadPool problem
I'm in the process of updating a Delphi app from Indy 9 to Indy 10.
It's quite painful, as apparently a lot has changed.
I'm stuck at one step.
Here is the old code (working with Indy 9):
A Thread Pool is created and every thread of the pool is initialized and then started.
The individual threads create an indy http client (but it does not matter here).
I've looked for a replacement and TIdSchedulerOfThreadPool looks like a winner,
but I cannot get it running.
Here is the modified (Indy 10) code:
It's quite painful, as apparently a lot has changed.
I'm stuck at one step.
Here is the old code (working with Indy 9):
A Thread Pool is created and every thread of the pool is initialized and then started.
The individual threads create an indy http client (but it does not matter here).
TUrlThread = class(TIdThread)
...
var
i: Integer;
begin
// create the Pool and init it
Pool := TIdThreadMgrPool.Create(nil);
Pool.PoolSize := Options.RunningThreads;
Pool.ThreadClass:= TUrlThread;
// init threads and start them
for i := 1 to Options.RunningThreads do
begin
with (Pool.GetThread as TUrlThread) do
begin
Index := i;
Controler := Self;
Priority := Options.Priority;
Start;
end;
end;
The TIdThreadMgrPool class is gone with Indy 10.I've looked for a replacement and TIdSchedulerOfThreadPool looks like a winner,
but I cannot get it running.
Here is the modified (Indy 10) code:
TUrlThread = class(TIdThreadWithTask)
...
var
i: Integer;
begin
// create the Pool and init it
Pool := TIdSchedulerOfThreadPool.Create(nil);
Pool.PoolSize := Options.RunningThreads;
Pool.ThreadClass:= TUrlThread;
// init threads and start them
for i := 1 to Options.RunningThreads do
begin
with (Pool.NewThread as TUrlThread) do
begin
Index := i;
Controler := Self;
Priority := Options.Priority;
Start;
end;
end;
I get an access violation exception here (this is indy code):procedure TIdTask.DoBeforeRun;
begin
FBeforeRunDone := True;
BeforeRun;
end;
FBeforeRunDone is nil.
ASKER
I've installed indy 10.1.5 about 1 week ago. This version has no playground folder.
If there is a newer version, would you please give me the direct URL of the installer.
The projectindy website often directs to 404 errors.
If there is a newer version, would you please give me the direct URL of the installer.
The projectindy website often directs to 404 errors.
Here is source for newer than yours:
ftp://indy.fulgan.com/ZIP/
... use this document to get daily snapshot version:
http://indy.fulgan.com/Get ting%20the %20latest% 20Indy%201 0%20snapsh ot%20using %20Tortois e%20SVN.pd f
http://www.projectindy.org /Sockets/D ownload/De vSnapshot. EN.aspx
... and here install instruction:
http://www.indyproject.org /sockets/D ocs/Indy10 Installati on.en.aspx
http://stackoverflow.com/q uestions/9 31371/inst all-the-la test-build -of-indy-1 0-on-delph i-2009
ftp://indy.fulgan.com/ZIP/
... use this document to get daily snapshot version:
http://indy.fulgan.com/Get
http://www.projectindy.org
... and here install instruction:
http://www.indyproject.org
http://stackoverflow.com/q
ASKER
I did a SVN checkout of the daily Indy 10 and Indy 10 demos.
Unfortunately the problem remains, and the demos don't have an example that uses TIdSchedulerOfThreadPool (die a grep in all .pas files for it).
Unfortunately the problem remains, and the demos don't have an example that uses TIdSchedulerOfThreadPool (die a grep in all .pas files for it).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
got answer on another forum and posted a link
http://www.projectindy.org
In source folder is Playgrounds folder with TIdSchedulerOfThreadPool example.