Note that there are some explanatory texts on larger screens.

plurals
  1. POMigrating from Indy 9 to 10 with Delphi, TIdSchedulerOfThreadPool initialization
    text
    copied!<p>I'm in the process of updating a Delphi app from Indy 9 to Indy 10.</p> <p>It's quite painful, as apparently a lot has changed.</p> <p>I'm stuck at one step.</p> <p>Here is the old code (working with Indy 9):</p> <p>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).</p> <pre><code>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; </code></pre> <p>The <strong>TIdThreadMgrPool</strong> class is gone with Indy 10.</p> <p>I've looked for a replacement and <strong>TIdSchedulerOfThreadPool</strong> looks like a winner, but I cannot get it running.</p> <p>Here is the modified (Indy 10) code:</p> <pre><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; </code></pre> <p>I get an access violation exception here (this is indy code):</p> <pre><code>procedure TIdTask.DoBeforeRun; begin FBeforeRunDone := True; BeforeRun; end; </code></pre> <p>FBeforeRunDone is nil.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload