1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
type
TZLResultEvent = procedure(Sender: TObject; const ResultValue: string) of object;
TZakaria = class(TThread)
private
FParam1: Double;
FParam2: Integer;
FResult: string;
FOnResult: TZLResultEvent;
procedure DoResult();
protected
procedure Execute(); override;
public
constructor Create(AParam1: Double; AParam2: Integer; AOnResult: TZLResultEvent);
end;
constructor TZakaria.Create(AParam1: Double; AParam2: Integer; AOnResult: TZLResultEvent);
begin
inherited Create(False);
FreeOnTerminate := True;
FParam1 := AParam1;
FParam2 := AParam2;
FOnResult := AOnResult;
end;
procedure TZakaria.Execute();
begin
if AParam2 = 0 then
FResult := FloatToStr(AParam1 * AParam1);
else
FResult := FloatToStr(AParam1 / AParam2);
Synchronize(DoResult);
end;
procedure TZakaria.DoResult();
begin
if Assigned(FOnResult)
FOnResult(Self, FResult);
end; |
Partager