SafeDictionaryTKey, TValueUseWeakReferences Property |
If true, the weak references are used for the items so the memory can be cleared upon request.
The property can be set only when the dictionary is empty. To ensure thread-safety, you have
to perform the check for emptiness and property assignment in a critical section (use
SyncRoot for that purpose).
Namespace: CMS.BaseAssembly: CMS.Base (in CMS.Base.dll) Version: 10.0.0
Syntax public bool UseWeakReferences { get; set; }
Property Value
Type:
BooleanExamples
Use the following code snippet to ensure thread-safety while changing this property.
lock (dictionary.SyncRoot)
{
dictionary.Clear();
dictionary.UseWeakReferences = true;
}
See Also