C# 클래스 Watchdog.Validation.Core.Util.ReentrancyGuard

A utility class which helps guard against reentrancy. This is safer and cleaner alternative to the typical pattern of adding a bool flag to a class, and setting it to true when you wish to guard, then resetting it back to false. The ReentrancyGuard returns an IDisposable token when call its Set method. From this point on, its IsSet property will be true. When you wish to exit out of the safe block, call Dispose on the token. The best usage is within a using block: // class member: private readonly ReentrancyGuard guard; // to protect a block from reentrancy: using (this.guard.Set()) { ... safe code } And wherever you need to guard: if (this.guard.IsSet) { return; } This class is meant to be used only a single thread.
파일 보기 프로젝트 열기: JDolinger/Watchdog 1 사용 예제들

공개 메소드들

메소드 설명
Set ( ) : IDisposable

메소드 상세

Set() 공개 메소드

public Set ( ) : IDisposable
리턴 IDisposable