Solved

Migrating from Indy 9 to 10 with Delphi, TIdSchedulerOfThreadPool problem

Posted on 2013-01-23
7
882 Views
Last Modified: 2013-12-03
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
Comment
Question by:Casady
  • 4
  • 2
7 Comments
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 38823170
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
 

Author Comment

by:Casady
ID: 38823196
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
 
LVL 26

Expert Comment

by:Sinisa Vuk
ID: 38824572
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Casady
ID: 38835128
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
 

Accepted Solution

by:
Casady earned 0 total points
ID: 38846484
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
 

Author Closing Comment

by:Casady
ID: 39073084
got answer on another forum and posted a link
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Read about why website design really matters in today's demanding market.
I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now