[beginner] Help needed with threads + Forms

From: Gerhard Haslberger (ghaslbe_at_gmx.de)
Date: 03/21/04


Date: Sun, 21 Mar 2004 13:27:48 +0100

hi,

i create a form in my mainprg

    Download1 := TDownloadForm.create(Form1);
    Download1.show;
    Download1.startDownload('a','b');
    Download1.close;
    Download1.free;

in this form i start a thread in startDownload and startDownload also waits
until the thread is finished.

Problem:
I want to access other methods of TDownloadForm in the "Sycronised(Methods)"
in this threads but how can i call it there?
Download1 does not work bec its only known in the mainprogram...

Can i (and how? (type?) ) give the constructor of the thread a pointer to my
instance of TDownloadForm and then in the "Sycronised(Methods)"
call it via pointer.method_of_downloadform();

Can this work and/or what can i do?

---------------- src-example -------------

TDownloadForm = class(TForm)
   ...
    procedure doinstall;
    procedure startDownload(bla...);
  ...
private
    MyClientThread: TMyClientThread;
end;

procedure TDownloadForm.startDownload(in_filename: String; in_outputdir:
String);
begin
  MyClientThread :=TMyClientThread.Create(False, Socket,filename);
end;

procedure TMyClientThread.Execute;
begin
...
  Synchronize(DisplayMemoryStream);
....
end;

procedure TMyClientThread.DisplayMemoryStream;
begin
  HOWCANICALLIT.doinstall;
end;

procedure TDownloadForm.doinstall;
Begin
....
end;