naja du könntest deine objectlist mit nem lock schützen - dann brauchst nich mit mutexi rumtüdeln
Delphi-Quellcode:
type
TJooObjectList = class(TObjectList)
private
FCriticalSection: TRTLCriticalSection;
public
constructor Create; override;
destructor Destroy; override;
function Lock: TObjectList;
procedure UnLock;
end;
imple...
constructor TJooObjectList.Create;
begin
inherited Create;
InitializeCriticalSection(FCriticalSection);
end;
destructor TJooObjectList.Destry;
begin
DeleteCriticalSection(FCriticalSection);
inherited Destroy;
end;
function TJooObjectList.Lock: TObjectList;
begin
EnterCriticalSection(FCriticalSection);
Result := Self;
end;
procedure TJooObjectList.Unlock;
begin
LeaveCriticalSection(FCriticalSection);
end;
procedure tblah.foobar;
var
xLock: TObjectList;
begin
xLock := xObjList.Lock;
try
...
finally
xObjList.UnLock;
end;
end;