Class TRTLCriticalSection

View Code
TCriticalSection = class(TObject)
protected
FSection: TRTLCriticalSection;
public
constructor Create;
destructor Destroy; override;
procedure Enter;
procedure Leave;
function TryEnter: Boolean;
end;

{TCriticalSection}
constructor TCriticalSection.Create;
begin
InitializeCriticalSection(FSection);
end;

destructor TCriticalSection.Destroy;
begin
DeleteCriticalSection(FSection);
end;

procedure TCriticalSection.Enter;
begin
EnterCriticalSection(FSection);
end;

procedure TCriticalSection.Leave;
begin
LeaveCriticalSection(FSection);
end;

function TCriticalSection.TryEnter: Boolean;
begin
Result :
= TryEnterCriticalSection(FSection);
end;

posted @ 2011-06-06 10:25  Jekhn  阅读(372)  评论(0编辑  收藏  举报