Thank you Nello, David I will definetely look at your suggestions.

In the meanwhile I think I found a quick and dirty solution (keeping in mind
that I only need this functionality to test the component and will remove it
later).

For that I have a global slResp: TStringList (gl... - yes, I know ...)
declared in the component. I also have a comp's method:

function TTransactionManager.GetResponse: String;
begin
  if slResp.Count > 0 then begin
    Result := slResp[slResp.Count - 1];
    slResp.Clear;
  end
  else
    Result := '';
end;

I also have a global bNotLocked: Boolean = True and a thread method:

procedure TTransactionThread.SetResponseList;
var
  bRepeated : Boolean;
begin
  bRepeated := False;

  // make sure that threads access a global list object in sequence
  repeat
    if bRepeated then begin
      Sleep(1000);
    end
    else begin
      bRepeated := True;
    end;
  until bNotLocked; // global flag

  // lock the loop
  bNotLocked := False;

  try
    slResp.Text := slResponse.Text; // thread list
    Sleep(100); // give a form time to get the string/s from global list
  finally
    bNotLocked := True;
  end;
end;

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
and finally a form's timer handler

procedure TMainForm.Timer2Timer(Sender: TObject); // interval = 10
var
  s : String;
begin
  if TrManager <> nil then begin
    s := TrManager.GetResponse;
    if Trim(s) <> '' then
      memRcvMessage.Lines.Add(s);
  end;
end;

I realise it's not very clean, but hey, it's a cheat.

Best regards.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to