ESemaphoreException - Exemples

ESemaphoreException = class (Exception)Interface de ESemaphoreExceptionExemples de ESemaphoreException
uses System.IO.Semaphore;

try

   // ... Actions avant la prise du sémaphore ...

   var semaphore := TSemaphore.Create('G:\Temp\tempo.lock', 'test');
   semaphore.Enter(1000);

   // ... Actions après la prise du sémaphore ...

except
   // On traite différemment en cas d'erreur due au sémaphore
   on e: ESemaphoreException do begin
      PrintLn('ERR SEMAPHORE : '+e.Message);
   end;
   on e: Exception do begin
      PrintLn('ERR : '+e.Message);
   end;
end;