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;


分享给朋友:
您可能感兴趣的文章:
随机阅读: