Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- type
- TMyThread = class(TThread)
- private
- fLowerLimit: Integer;
- fUpperLimit: Integer;
- procedure UpdateMainThread;
- protected
- procedure Execute; override;
- public
- constructor Create(lValue, uValue: Integer; Suspended: Boolean);
- end;
- implementation
- uses MainForm; //Unit of the form that will be updated by thread
- constructor TMyThread.Create(lValue, uValue: Integer; Suspended: Boolean);
- begin
- Inherited Create(Suspended);
- fLowerLimit := lValue;
- fUpperLimint := uValue;
- FreeOnTerminate := True;
- end;
- procedure TMyThread.Execute;
- var
- I: Integer;
- begin
- For I := fLowerLimit to fUpperLimit do
- if (I mod 10) = 0 then
- Synchronize(UpdateMainThread);
- end;
- procedure TMyThread.UpdateMainThread;
- begin
- MainForm.Memo1.Lines.Add('Hello World');
- end;
- end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement