En/na A.J. Venter ha escrit:


So while it´s true that I don´t use FOutPut in this class -that is because I want to be able to use it in the calling application.
Having explained this, does it clarify why the code looks as it does ?

Ok, but in your test program I think you don't give synchronize a chance to do its "magic" (I'd use another word but I want to be polite ;-). I doubt it will solve your problem but you should call Application.ProcessMessages in the wait loop. BTW you could write a different creator to simplify things (and make it more readable IMHO), e.g.

instead of

procedure TForm1.Button1Click(Sender: TObject);
begin
  MyProcess := TThreadedProcess.Create(True);
  MyProcess.Command := Edit1.Text;
  Button1.Enabled := False;
  MyProcess.Resume;
    While MyProcess.Running do
       sleep(100);
   Button1.Enabled := True;
   Memo1.Lines.Assign(MyProcess.OutPut);
   MyProcess.Free;
end;


procedure TForm1.Button1Click(Sender: TObject);
begin
  Button1.Enabled:=False;
  MyProcess := TThreadedProcess.Create(Edit1.Text,Memo1.Lines);
  While MyProcess.Running do
    begin
       sleep(100);
       Application.ProcessMessages;
   Button1.Enabled := True;
   MyProcess.Free;
end;


where the constructor is something like

constructor TThreadedProcess.Create(command:string;output:TStringList);
begin
   FRunning := False;
   FCommand := command;
   FOutPut := TStringList.Create;
   FRealOutput := output;
   FreeOnTerminate := False;
   inherited Create(False);
end;

Bye
--
Luca Olivetti
Wetron Automatización S.A. http://www.wetron.es/
Tel. +34 93 5883004      Fax +34 93 5883007

_________________________________________________________________
    To unsubscribe: mail [EMAIL PROTECTED] with
               "unsubscribe" as the Subject
  archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to