On Mon, 28 Nov 2011, Graeme Geldenhuys wrote:

On 28/11/2011, michael.vancann...@wisa.be <michael.vancanneyt@....> wrote:

The mistake you make is that you create a loop in the thread;
The thread does not need a loop. It just needs to set Active to true:

Procedure TMyServerThread.Execute;

begin
   MyServer.Active:=True;
end;

OK thanks, I got it working now but it is not ideal yet.

It is still problematic if you try starting & stopping the HTTP Server
because if you stop it, TThread.Execute completes, thus you can't
restart it again, you need to create a new thread instance. I guess
not the end of the world for my simple example, but might be for other
more complex apps. But then, that was probably not the design goal of
this component.

I am open for suggestions, but the possible solutions are IMHO not so simple:
- Either a thread must be created automatically to actually run the server when 
Active:=True
- Or the server must be made non-blocking and then you need to run an event 
loop.

Either way is a significant architectural change.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to