[...] coffee, pencil and stuff ;-) off course, the local procedure "internalEnter" in Leave is a copy'n'paste rubbish. Just remove ..
TCriticalSection.Leave; begin internal.lock; try if OwnerThread <> GetCurrentThreadID then begin //we are not // allowed to leave, because we don't own it! raise exception.create('leave on a foreign critical section'); end else begin //we are the owner if fLockCount = 0 then begin raise exception.create('leave on a unlocked section'); end else begin dec(fLockCount); if fLockCount=0 then rtlSetEvent(fExternalLock); end; end; finally internal.unlock; end; end; _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-pascal