Jup daher die "" .. ...
Nun mal die Frage ob man es so tun kann, oder ob das besser geht?
Delphi-Quellcode:
unit UnitCopyThread;
interface
uses
System.Classes,System.IOUtils;
type
TCopyThread =
class(TThread)
private
FSource, FDestination: PChar;
FFinished: Boolean;
{ Private-Deklarationen }
public
constructor Create(aSource,aDestination: PChar);
function isFinished: Boolean;
{ Public-Deklarationen }
protected
procedure Execute;
override;
end;
implementation
constructor TCopyThread.Create(aSource, aDestination: PChar);
begin
inherited Create (false) ;
FreeOnTerminate:= True;
FSource:= aSource;
FDestination:= aDestination;
end;
procedure TCopyThread.Execute;
begin
FFinished:= False;
TDirectory.copy(FSource,FDestination);
FFinished:= True;
{ Thread-Code hier einfügen }
end;
function TCopyThread.isFinished: Boolean;
begin
if FFinished = True
then Result:= True
else Result:= False
end;
end.
und Ausführung
Delphi-Quellcode:
procedure MDir.btnTestClick(Sender: TObject);
var
LCopyThread: TCopyThread;
begin
LCopyThread:= TCopyThread.Create('D:\1','D:\2');
try
while LCopyThread.isFinished = false do
begin
Application.ProcessMessages;
Sleep(100);
end;
finally
LCopyThread.Terminate;
end;
end
Das andere schau ich mir gleich mal an von Hathor