本文整理汇总了C#中ConcurrentDictionary.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ConcurrentDictionary.Remove方法的具体用法?C# ConcurrentDictionary.Remove怎么用?C# ConcurrentDictionary.Remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConcurrentDictionary
的用法示例。
在下文中一共展示了ConcurrentDictionary.Remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestDuplicateRemove
public void TestDuplicateRemove()
{
var dict = new ConcurrentDictionary<int, string>();
dict.Add(3, string.Empty);
dict.Remove(3);
dict.Remove(3);
}
示例2: TestLockFreeDictionary
public void TestLockFreeDictionary()
{
IDictionary<int, Guid> dict = new ConcurrentDictionary<int, Guid>();
KeyValuePair<int, Guid> test = new KeyValuePair<int, Guid>(-64, Guid.NewGuid());
dict.Add(42, Guid.NewGuid());
dict.Add(22, Guid.NewGuid());
dict.Add(test);
dict.Add(55, Guid.NewGuid());
Assert.IsTrue(dict.ContainsKey(-64));
Assert.IsTrue(dict.Contains(test));
Assert.IsFalse(dict.Contains(new KeyValuePair<int, Guid>(-64, new Guid())));
dict[-64] = Guid.NewGuid();
Assert.IsFalse(dict.Contains(test));
Guid newID = Guid.NewGuid();
dict[12] = newID;
Guid id = dict[12];
Assert.IsTrue(newID == id);
Assert.IsTrue(dict.Count == 5);
dict.Remove(-64);
Assert.IsTrue(dict.Count == 4);
}
示例3: Remove_WithKeyValuePairThrowsNotImplementedException
public void Remove_WithKeyValuePairThrowsNotImplementedException()
{
// Arrange
ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();
// Act/Assert
Assert.Throws<NotImplementedException>(() => dictionary.Remove(new KeyValuePair<int, int>(0, 0)));
}
示例4: Remove_ThrowsNotImplementedException
public void Remove_ThrowsNotImplementedException()
{
// Arrange
ConcurrentDictionary<int, int> dictionary = new ConcurrentDictionary<int, int>();
// Act/Assert
Assert.Throws<NotImplementedException>(() => dictionary.Remove(0));
}
示例5: LoadChannels
private void LoadChannels(ConcurrentDictionary<ulong, UserEventCallback> dict)
{
foreach (var pair in dict)
{
try
{
pair.Value.Channel = _client.GetServer(pair.Key).GetChannel(pair.Value.ChannelId);
}
catch (NullReferenceException)
{
Logger.FormattedWrite("AnnounceLoad",
$"Failed loading channel {pair.Value.ChannelId} for server {pair.Key}. Removing",
ConsoleColor.Yellow);
dict.Remove(pair.Key);
}
}
}