I know i have posted a similar question before but i am not able to get it working I have this simple code :
procedure TfrmMain.srvrConnect(AContext: TIdContext); //idhttpserver on connect event
var
S,C : String;
begin
repeat
s := s + AContext.Connection.Socket.ReadChar;
until AContext.Connection.Socket.InputBufferIsEmpty = True;
frmMain.caption := S;
Memo1.Lines.Add(S);
end;
The strings displays ok in the memo but the caption doesn’t get updated
TIdHTTPServeris a multi-threaded component.TIdContextruns in its own worker thread. You cannot safely update the Form’sCaption(or do anything else with the UI) from outside of the main thread. You need to synchronize with the main thread, such as with theTIdSyncorTIdNotifyclass.On a side note, calling
ReadChar()in a loop is very inefficient, not to mention error-prone if you are using Delphi 2009+ since it cannot return data for surrogate pairs.Use something more like this instead;