• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 974
  • Last Modified:

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).
  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;

Open in new window

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;

Open in new window

I get an access violation exception here (this is indy code):
procedure TIdTask.DoBeforeRun;
begin
  FBeforeRunDone := True;
  BeforeRun;
end;

Open in new window

FBeforeRunDone is nil.
0
Casady
Asked:
Casady
  • 4
  • 2
1 Solution
 
Sinisa VukCommented:
Try to install  latest version of Indy.
http://www.projectindy.org/Sockets/Download/DevSnapshot.EN.aspx
In source folder is Playgrounds folder with TIdSchedulerOfThreadPool example.
0
 
CasadyAuthor Commented:
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.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
CasadyAuthor Commented:
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).
0
 
CasadyAuthor Commented:
I've received the solution in another forum.

In case someone else has this problem please see here:

http://stackoverflow.com/questions/14514810/migrating-from-indy-9-to-10-with-delphi-tidschedulerofthreadpool-initialization/14519101#14519101
0
 
CasadyAuthor Commented:
got answer on another forum and posted a link
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now