Lazarus

Programming => Networking and Web Programming => Topic started by: SirTwist on November 20, 2021, 08:05:57 pm

Title: fpweb/fcl-web: TCustomHTTPApplication and TThread.Queue/Synchronize
Post by: SirTwist on November 20, 2021, 08:05:57 pm
Good Evening, dear fellows,

I am just trying my first steps with fpWeb and the standalone http server.
In addition to the standard framework I added a data module which I instantiated within the main application:
Code: Pascal  [Select][+][-]
  1. begin
  2.   Application.Title:='webserver';
  3.   Application.CreateForm(TdmMain, dmMain);
  4.   Application.Port:=4040;
  5.   Application.LegacyRouting := False;
  6.   Application.Threaded:=True;
  7.   Application.Initialize;
  8.   Application.Run;
  9. end.

The web application itself is multithreaded, and so I want to synchronize some activities with the main thread. In "normal" (GUI) applications I call therefor TThread.Queue(@do_something) and everything works fine. In TCustomHTTPApplication, nothing will happen, and with a TThread.Synchronize the program will hang completly.

Has anyone a clue what is missing or what I am doing wrong here?

Kind regards,
Sir Twist
Title: Re: fpweb/fcl-web: TCustomHTTPApplication and TThread.Queue/Synchronize
Post by: Warfley on November 30, 2021, 03:09:12 pm
It seems that the FCL Web Applications don't check the message queue on the mainthread.
It also doesn't make sense, because the main thread should server the clients as fast as possible.

If you want to synchronize your threads, you need to do that yourself in a custom thread
TinyPortal © 2005-2018