Click or drag to resize
SafeDictionaryTKey, TValueAddMultiple Method
Adds multiple items with same value to the dictionary

Namespace: CMS.Base
Assembly: CMS.Base (in CMS.Base.dll) Version: 9.0.0
Syntax
C#
public void AddMultiple(
	string[] items,
	bool value
)

Parameters

items
Type: SystemString
Items to add
value
Type: SystemBoolean
Items value
Remarks
The operation is not performed in a critical section. If you want to make sure no other thread modifies the dictionary (e.g. adds/removes an item) while the dictionary is being filled with items, use the SyncRoot.
Examples
Use the following snippet to make sure no other thread modifies the dictionary while it is being populated by items.
string[] items = GetItems(...);
lock (dictionary.SyncRoot)
{
    dictionary.AddMultiple(items, true);

    // All the items are set to true now
}
The following approach is also thread-safe, but the result may differ from the previous one if another thread performs any write operation while the items are being added.
string[] items = GetItems(...);
dictionary.AddMultiple(items, true);

// Any other thread might have modified some entry (i.e. the items are not guaranteed to be set to true)
See Also