SafeDictionaryTKey, TValueAddMultiple Method |
Adds multiple items with same value to the dictionary
Namespace: CMS.BaseAssembly: CMS.Base (in CMS.Base.dll) Version: 12.0.0
Syntax 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);
}
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);
See Also