Allan, The thread does not block on the second call to Acquire, but if the routine has a deep recursion level, Acquire/Release will be called many times, plus the try ... finally block will also be executed many times. This is rather inefficient - it is better to write a wrapper method that only locks the critical section once.
Dennis. ----- Original Message ----- From: "Allan, Samuel" <[EMAIL PROTECTED]> To: "NZ Borland Developers Group - Delphi List" <[EMAIL PROTECTED]> Sent: Thursday, February 12, 2004 4:50 PM Subject: [DUG] TCriticalSection > Quick question, I think I'm right, but I just want confirmation: > > If a thread calls Aquire a second time on the same TCriticalSection, > then the thread does not block right? > > The thread does not release the TCriticalSection until all calls to > Aquire have been matched by a call to Release? > > I have a recursive method that needs to be locked away behind a > TCriticalSection. Like I can rewrite so there's no problem, but this is > easier. > > procedure RecursiveMethod; > begin > criticalSection.Aquire; > try > ... > RecursiveMethod; > ... > finally > critcalSection.Release; > end; > end; > > _______________________________________________ > Delphi mailing list > [EMAIL PROTECTED] > http://ns3.123.co.nz/mailman/listinfo/delphi > _______________________________________________ Delphi mailing list [EMAIL PROTECTED] http://ns3.123.co.nz/mailman/listinfo/delphi
