static void TestParallelModifications() { using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("parallel")) { dic.Add("hello", "world"); dic["hello"].ShouldBe("world"); using (DictionaryQuery <string> pdic = cx.DictionaryQuery <string>("parallel")) { pdic["hello"] = "you"; } dic.ShouldContainKey("hello"); dic["hello"].ShouldBe("you"); dic.Clear(); } }
static async Task TestMultithreading() { Random rand = new Random(); using (DictionaryQuery <string> dic = cx.DictionaryQuery <string>("async")) { for (int i = 0; i < 15; i++) { if (!dic.ContainsKey("nb" + i)) { await Task.Delay(rand.Next(1000)); dic["nb" + i % 2] = "whatever" + i; } } dic.Clear(); } }