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 := msgWaitforMultipleObjects(length(ThreadArray), ThreadArray, true, 10, QS_ALLINPUT);
if dwWaitResult <> WAIT_OBJECT_0
then
begin
Application.ProcessMessages;
// GUI aktualisieren
PeekMessage(msg, Application.Handle, 0, 0, PM_REMOVE);
PeekMessage(msg, SearchForCopy.Handle, 0, 0, PM_REMOVE);
PeekMessage(msg, SearchForDelete.Handle, 0, 0, PM_REMOVE);
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;