Talk:Multithreaded Application Tutorial

From Free Pascal wiki
Revision as of 16:00, 25 January 2010 by Lrlr (talk | contribs) (New page: procedure TMyThread.Execute; var newStatus : string; begin fStatusText := 'TMyThread Starting...'; Synchronize(@Showstatus); fStatusText := 'TMyThread Running...'; thi...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

procedure TMyThread.Execute;

 var
   newStatus : string;
 begin
   fStatusText := 'TMyThread Starting...';
   Synchronize(@Showstatus);
   fStatusText := 'TMyThread Running...';

this is a very good example of what you should NEVER do..

Showstatus will NEVER display the text 'TMyThread Starting...';

will show "TMyThread Running..." maybe twice ...

change your main-thread code to:

 procedure TForm1.ShowStatus(Status: string);
 begin
   memo1.Lines.Add(Status);
 end;


and you will see what i mean..