2using System.Threading.Tasks;
22 semaphores.Removed += Semaphores_Removed;
29 return Task.CompletedTask;
40 semaphores[Key] = Result;
53 public static async Task<Semaphore>
BeginRead(
string Key)
67 return GetSemaphore(Key).
EndRead();
90 public static async Task<Semaphore>
BeginWrite(
string Key)
104 return GetSemaphore(Key).
EndWrite();
Implements an in-memory cache.
Event arguments for cache item removal events.
ValueType Value
Value of item that was removed.
Represents an object that allows single concurrent writers but multiple concurrent readers....
virtual async Task< bool > TryBeginRead(int Timeout)
Waits, at most Timeout milliseconds, until object ready for reading. Each successful call to TryBegi...
virtual Task EndWrite()
Ends a writing session of the object. Must be called once for each call to BeginWrite or successful c...
virtual async Task< bool > TryBeginWrite(int Timeout)
Waits, at most Timeout milliseconds, until object ready for writing. Each successful call to TryBegi...
virtual async Task BeginWrite()
Waits until object ready for writing. Each call to BeginWrite must be followed by exactly one call to...
virtual Task< int > EndRead()
Ends a reading session of the object. Must be called once for each call to BeginRead or successful ca...
virtual async Task< int > BeginRead()
Waits until object ready for reading. Each call to BeginRead must be followed by exactly one call to ...
Represents a named semaphore, i.e. an object, identified by a name, that allows single concurrent wri...
Static class of application-wide semaphores that can be used to order access to editable objects.
static Task< bool > TryBeginRead(string Key, int Timeout)
Waits, at most Timeout milliseconds, until the semaphore identified by Key is ready for reading....
static async Task< Semaphore > BeginRead(string Key)
Waits until the semaphore identified by Key is ready for reading. Each call to BeginRead must be fol...
static Task< bool > TryBeginWrite(string Key, int Timeout)
Waits, at most Timeout milliseconds, until the semaphore identified by Key is ready for writing....
static Task EndRead(string Key)
Ends a reading session of the semaphore identified by Key . Must be called once for each call to Begi...
static Task EndWrite(string Key)
Ends a writing session of the semaphore identified by Key . Must be called once for each call to Begi...
static async Task< Semaphore > BeginWrite(string Key)
Waits until the semaphore identified by Key is ready for writing. Each call to BeginWrite must be fo...