Ich habe deinen Source mal etwas überarbeitet (hier nur die geänderten Teile):
Delphi-Quellcode:
procedure TCustomThread.SetCancel(const Value: Boolean);
begin
if (FCancel <> Value) then
begin
FCancel := Value;
if Value then
Terminate;
end;
end;
procedure TCustomThread.Execute;
var
I : Integer;
begin
Stream := TFileStream.Create(FFileName, fmOpenRead);
try
FIsOpen:= Stream.Handle <> INVALID_HANDLE_VALUE;
if FIsOpen then
begin
StreamSize := Stream.Size;
I := 10;
while (StreamSize div I) > MaxInteger do
I := I * 10;
iSize := StreamSize div I;
end;
Extract;
finally
Stream.Free;
end;
end;
procedure TCustomThread.Extract;
var
iRead : Int64;
begin
if FIsOpen then
begin
while (ReadSize <> StreamSize) and (not Terminated) do
begin
iRead:= iSize;
Inc(ReadSize, iRead);
if (StreamSize - ReadSize) < iSize then
iSize := StreamSize - ReadSize;
if Assigned(FOnProgress) then
Synchronize(DoProgress);
Sleep(50);
end;
end;
end;
procedure TCustomThread.TerminatedSet;
begin
end;