try
SearchForDelete := TSearchDelete.Create(False);
SearchForDelete.FreeOnTerminate := False;
SearchForCopy := TSearchCopy.Create(False);
SearchForCopy.FreeOnTerminate := False;
ThreadArray[0] := SearchForCopy.Handle;
// Handle Array füllen
ThreadArray[1] := SearchForDelete.Handle;
repeat
// Auf Threads warten
dwWaitResult := WaitforMultipleObjects(length(ThreadArray), @ThreadArray, true, 10);
if dwWaitResult <> WAIT_OBJECT_0
then
begin
Application.ProcessMessages;
// GUI aktualisieren
end;
if CancelSync
then
begin
TerminateThread(ThreadArray[0], 0);
TerminateThread(ThreadArray[1], 0);
dwWaitResult := WAIT_OBJECT_0;
end;
until dwWaitResult = WAIT_OBJECT_0;
// keinen Threads mehr zum warten
finally
SearchForCopy.Free;
SearchForDelete.Free;
end;