Class TRTLCriticalSection

来源:互联网 时间:1970-01-01

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;


相关阅读:
Top