C# 클래스 SimpleHelpers.NamedLock

Synchronization helper: a static lock collection associated with a key. NamedLock manages the lifetime of critical sections that can be accessed by a key (name) throughout the application. It also have some helper methods to allow a maximum wait time (timeout) to aquire the lock and safelly release it. Note: this nuget package contains c# source code and depends on System.Collections.Concurrent introduced in .Net 4.0.
상속: IDisposable
파일 보기 프로젝트 열기: khalidsalomao/SimpleHelpers.Net 1 사용 예제들

공개 메소드들

메소드 설명
CreateAndEnter ( string key ) : NamedLock

Creates a new instance and tries to aquire a lock.

CreateAndEnter ( string key, System.TimeSpan waitTimeout ) : NamedLock

Creates a new instance and tries to aquire a lock.

CreateAndEnter ( string key, int waitTimeoutMilliseconds ) : NamedLock

Creates a new instance and tries to aquire a lock.

Dispose ( ) : void

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Releases aquired lock and related resources.

Enter ( ) : bool

Tries to aquire a lock.

Enter ( System.TimeSpan waitTimeout ) : bool

Tries to aquire a lock respecting the specified timeout.

Enter ( int waitTimeoutMilliseconds ) : bool

Tries to aquire a lock respecting the specified timeout.

Exit ( ) : bool

Releases the lock if it was already aquired. Called also at "Dispose".

NamedLock ( string key ) : System

Initializes a new instance of the NamedLock class.

비공개 메소드들

메소드 설명
GetOrAdd ( string key ) : object
LockFactory ( string key ) : CountedLock
ReleaseOrRemove ( string key ) : void

메소드 상세

CreateAndEnter() 공개 정적인 메소드

Creates a new instance and tries to aquire a lock.
public static CreateAndEnter ( string key ) : NamedLock
key string The named lock key.
리턴 NamedLock

CreateAndEnter() 공개 정적인 메소드

Creates a new instance and tries to aquire a lock.
public static CreateAndEnter ( string key, System.TimeSpan waitTimeout ) : NamedLock
key string The named lock key.
waitTimeout System.TimeSpan The wait timeout.
리턴 NamedLock

CreateAndEnter() 공개 정적인 메소드

Creates a new instance and tries to aquire a lock.
public static CreateAndEnter ( string key, int waitTimeoutMilliseconds ) : NamedLock
key string The named lock key.
waitTimeoutMilliseconds int The wait timeout milliseconds.
리턴 NamedLock

Dispose() 공개 메소드

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources. Releases aquired lock and related resources.
public Dispose ( ) : void
리턴 void

Enter() 공개 메소드

Tries to aquire a lock.
public Enter ( ) : bool
리턴 bool

Enter() 공개 메소드

Tries to aquire a lock respecting the specified timeout.
public Enter ( System.TimeSpan waitTimeout ) : bool
waitTimeout System.TimeSpan The wait timeout.
리턴 bool

Enter() 공개 메소드

Tries to aquire a lock respecting the specified timeout.
public Enter ( int waitTimeoutMilliseconds ) : bool
waitTimeoutMilliseconds int The wait timeout milliseconds.
리턴 bool

Exit() 공개 메소드

Releases the lock if it was already aquired. Called also at "Dispose".
public Exit ( ) : bool
리턴 bool

NamedLock() 공개 메소드

Initializes a new instance of the NamedLock class.
public NamedLock ( string key ) : System
key string The named lock key.
리턴 System