[fpc-pascal] fcl-web TFPHttpServer component problem

Graeme Geldenhuys graemeg.lists at gmail.com
Mon Nov 28 14:38:43 CET 2011


On 28/11/2011, michael.vancanneyt at wisa.be <michael.vancanneyt at w.....> wrote:
>>
>> If so, that's a pretty dumb design.
>
> Ah. And why is that so ?

Now it's much less useful.

How are you supposed to "correctly" terminate the HTTP Server once
Active = True is called?


> If you want still to have a "main program", you should use a thread and
> create the component in the thread. Which is exactly what happens in a
> service application, the intended environment for the component.

I fail to see how this will resolve the problem, but that could be
contributed to my lack of experience with service-style projects. None
the less, I'll adapt my very simple test project and create the server
instance inside a thread, and see how it goes. Like I said, I still
can't see how you can cleanly terminate the HTTP server, because it
will never give the thread a chance to look at the value of
TThread.Terminated?

eg: (the following code is just from memory, not actually test)


procedure TMyThread.Execute;
begin
   while not Terminated do
   begin
     FHTTPServer.Active := True;       // We are stuck here forever
  end;
end;

or

procedure TMyThread.Execute;
begin
   FHTTPServer.Active := True;       // We are stuck here forever
   while not Terminated do
   begin
      // do something, but we will never get here
   end;
   FHTTPServer.Active := False;  // we will never get here either.
end;


-- 
Regards,
  - Graeme -


_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://fpgui.sourceforge.net



More information about the fpc-pascal mailing list