Einzelnen Beitrag anzeigen

FredlFesl

Registriert seit: 19. Apr 2011
293 Beiträge
 
Delphi 2009 Enterprise
 
#14

AW: Datenaustausch zwischen Threads (Sync)

  Alt 30. Sep 2011, 06:59
Delphi-Quellcode:
function ThreadValue.getNO2_10: Double;
begin
  try
    CSNO2_10.Acquire; // lock out other threads
    Result := FNO2_10;
  finally
    CSNO2_10.Release;
  end;
end;
Das Acquire muss vor das try.
Delphi-Quellcode:
MyCriticalSection.Acquire;
Try
  DoSomethingWhichMightCrash();
Finally
  MyCriticalSection.Release
End;
Das Bild hängt schief.
  Mit Zitat antworten Zitat