Amir Aavani wrote:
>
> InitCriticalSection (cs);
>
> while true do
> begin
> EnterCriticalsection (cs);
> WriteLn ('Here!');
> end;
> LeaveCriticalsection (cs);
Each Enter.. must be matched by a Leave..., and you don't need the loop.
The standard way of doing this is:
EnterCriticalsection (cs);
try
WriteLn ('Here!');
finally
LeaveCriticalsection (cs);
end;