ThreadSafeDictionaryTKey, TValueMergeInterval Property
Gets or sets the minimum lifetime for the temporarily created internal locking storage when adding new keys to the
ThreadSafeDictionaryTKey, TValue.
Default value: 100 milliseconds.
Namespace: KGySoft.CollectionsAssembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 10.0.0
public TimeSpan MergeInterval { get; set; }
Public Property MergeInterval As TimeSpan
Get
Set
public:
property TimeSpan MergeInterval {
TimeSpan get ();
void set (TimeSpan value);
}
member MergeInterval : TimeSpan with get, set
Property Value
TimeSpan When adding items with new keys, they will be put in a temporary locking storage first.
Whenever the locking storage is accessed, it will be checked whether the specified time interval has been expired since its creation. If so, then
it will be merged with the previous content of the fast non-locking storage into a new one.
If new keys are typically added together, rarely or periodically, then it is recommended to set some small positive value (up to a few seconds).
Even if the value of this property is TimeSpan.Zero, adding new items are not necessarily merged immediately
to the fast-accessing storage. Depending on the targeted platform a minimum 15 ms delay is possible. Setting TimeSpan.Zero
is not recommended though, unless new items are almost never added at the same time.
When the value of this property is negative (e.g. Timeout.InfiniteTimeSpan), then the locking storage is not merged
automatically with the lock-free storage. You still can call the EnsureMerged method to perform a merge explicitly.
This property is ignored if a value is accessed in the fast-accessing storage including removing and adding values of keys that have already been merged to the lock-free storage.
Some operations (such as enumerating the
ThreadSafeDictionaryTKey, TValue or its
Keys and
Values,
calling the
ToArray or the
ICollection.CopyTo implementations) as well as serializing the dictionary may trigger a merging
operation regardless the value of this property.