When calling the TryEnter method on a TCriticalSection the result is always true. Surely this should only return true if it is able to aquire the lock?
var
MyCritSect: TCriticalSection;
begin
MyCritSect := TCriticalSection.Create;
try
// MyCritSect.Enter;
Writeln(BoolToStr(MyCritSect.TryEnter, True)); // This should return True
Writeln(BoolToStr(MyCritSect.TryEnter, True)); // This should return False?
Readln;
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.
Even if you uncomment the MyCritSect.Enter;
line it still returns True for both calls to TryEnter.
I am using Delphi XE and Windows 10.