Danke, das hat geholfen. So schauts jetzt aus:
Delphi-Quellcode:
FWakeUpEvent := CreateEvent(
nil, false, false,
nil);
{...}
procedure TItemThread.Execute;
var
List: TList;
Item: PChar;
begin
while not Terminated
do
begin
if WaitForMultipleObjects(1, @FWakeUpEvent, false, INFINITE)
- WAIT_OBJECT_0 = 0
then
begin
repeat
Item :=
nil;
List := FItems.LockList;
try
if List.Count > 0
then
begin
Item := List[0];
List.Delete(0);
end;
finally
FItems.UnlockList;
end;
if (
not Terminated)
and Assigned(Item)
then
begin
Sleep(500);
// mit dem Item arbeiten
if not Terminated
then
Synchronize(
{ GUI aktualisieren } );
end;
until Terminated
or not Assigned(Item);
end;
end;
end;