CacheTKey, TValueGetThreadSafeAccessor Method

Gets a thread safe accessor for this CacheTKey, TValue instance. As it provides only a single readable indexer, it makes sense only if an item loader was passed to the appropriate constructor and the cache will not be accessed by other members but via the returned accessor.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.2.0
C#
public IThreadSafeCacheAccessor<TKey, TValue> GetThreadSafeAccessor(
	bool protectItemLoader = false
)

Parameters

protectItemLoader  Boolean  (Optional)
to ensure that also the item loader is locked if a new element has to be loaded and to allow the item loader to be called concurrently. In latter case the CacheTKey, TValue is not locked during the time the item loader is being called but it can happen that values for same key are loaded multiple times and all but one will be discarded. This parameter is optional.
Default value: .

Return Value

IThreadSafeCacheAccessorTKey, TValue
An IThreadSafeCacheAccessorTKey, TValue instance providing a thread-safe readable indexer for this CacheTKey, TValue instance.

Remarks

See Also