0

This question has been asked very often and I've spent hours reading, trying, testing with no result.

I guess it has to do with my older 2005 version.

Below is the code I tried after reading a post in the Embarcadero forum answered by Remy Lebeau:

Thread: How to handle multiple HTTP sessions with Indy10 TIdHTTPServer

procedure TMainForm.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
  Msg : String;
begin
  if ARequestInfo.QueryParams <> '' then
  begin
    Msg := DateTimeToStr(Now) + ': ReqParam "' + ARequestInfo.QueryParams + '"';
    TThread.Queue(nil,
      procedure
      begin
        Memo1.Lines.Add(Msg);
      end
    );
    AResponseInfo.ContentText := '<HTML><BODY>Query Params found.</BODY></HTML>';
  end
  else
  begin
    AResponseInfo.ContentText := '<HTML><BODY>Error: No Query Params.</BODY></HTML>';
    Msg := DateTimeToStr(Now) + ': Error: No Query Params';
    TThread.Queue(nil,
      procedure
      begin
        Memo1.Lines.Add(Msg);
      end
    );
  end;
end;

What I'm aiming for is accessing a memo or log file entry in a thread safe manner. Somehow using TThread.Synchronize() or TThread.Queue() doesn’t compile.

When adding the TThread.Queue() line as suggested by Remy, the error I get is:

E2029 Expression expected but procedure found

Does somebody have an alternative that I can use in Delphi 2005?

Edit: this is what I see from code completion:

The design view for TThread

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
D2005_MdK
  • 1
  • 2
  • 2
    Please add the code snip from the pic into the question... – Moshe Slavin Dec 31 '18 at 10:38
  • Welcome to Stack Overflow. Please show us your code as actual text, a [code snippet](https://stackoverflow.com/help/formatting). If the link of your image disappears, nobody will know what your question was. By [Asking a good question](https://stackoverflow.com/help/how-to-ask) you help us to understand you and your question/problem better, which in turn might give you a better and more specific response. Please also read [Why not upload images of code on SO when asking a question?](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-on-so-when-asking-a-question) – Virginia Dec 31 '18 at 11:29
  • The static versions of `TThread.Synchronize()` and `TThread.Queue()` have existed since D7 and D8, respectively, so they definitely exist in D2005. But, if you are having trouble using them, an alternative is Indy's `TIdSync` and `TIdNotify` classes, respectively. – Remy Lebeau Jan 01 '19 at 17:26
  • That puzzles me, as I don't see the TThread.Synchronize at all... I've added a screenshot... – D2005_MdK Jan 01 '19 at 17:48
  • @D2005_MdK then use `TThread.StaticSynchronize()` or `TThread.StaticQueue()`, both of which are clearly visible in your screenshot. – Remy Lebeau Jan 06 '19 at 06:25

0 Answers0