ThreadSafeHashSetTMergeInterval Property

Gets or sets the minimum lifetime for the temporarily created internal locking storage when adding new items to the ThreadSafeHashSetT.
Default value: 100 milliseconds.

Definition

Namespace: KGySoft.Collections
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.1.0
C#
public TimeSpan MergeInterval { get; set; }

Property Value

TimeSpan

Remarks

When adding new items, 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 items 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 (eg. 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 an item is accessed in the fast-accessing storage including removing and adding items that have already been merged to the lock-free storage.

  Note

Some operations (such as enumerating the ThreadSafeHashSetT, calling the ToArray or the ICollection.CopyTo implementations) as well as serialization may trigger a merging operation regardless the value of this property.

See Also