Thema: Delphi Thread Anfängerfrage

Einzelnen Beitrag anzeigen

Spurius

Registriert seit: 19. Aug 2003
294 Beiträge
 
Delphi 7 Professional
 
#44

Re: Thread Anfängerfrage

  Alt 27. Nov 2003, 16:41
Hallo,
es geht!!!!!!!!!!!!!!!!!!!!!!!!
Hier ist der Code:
Delphi-Quellcode:
unit threadtest;

interface

uses
  Classes,idtcpclient,dialogs,StdCtrls,sysutils;

type
  tmythread = class(TThread)
  private
    fclient:tidtcpclient;
    fmemo:tmemo;
    s:string;
    procedure updatememo;
  protected
    procedure Execute; override;
  public
   constructor create(const aclient: tidtcpclient;
   const amemo: tmemo);

  end;

implementation
uses modul;

constructor tmythread.create(const aclient: tidtcpclient;
         const amemo: tmemo);
begin
 inherited create(true);
 fclient := aclient;
 fmemo := amemo;
 resume;
end;

procedure tmythread.Execute;
begin
 while not terminated do
   begin
   s := fclient.readln;
   synchronize(updatememo);
   sleep(100);
   end;
end;


procedure tmythread.updatememo;
begin
 fmemo.Lines.Append(s);
end;
end.
Vielen Dank für die Hilfe, besonders an choose und kamil!
Gruß
Spurius
  Mit Zitat antworten Zitat