private void AutoCompleteProduct() { AutoCompleteStringCollection AutoItem = new AutoCompleteStringCollection(); ProductDictionary.Clear(); foreach (Product v in Product.List()) { AutoItem.Add((v.Name)); if (!ProductDictionary.ContainsKey(v.Name)) { ProductDictionary.Add(v.Name, v.Id); productCbx.Items.Add(v.Name); } } }
static void AddProducts(int count) { Parallel.For(0, count, (i) => { Product product = new Product { Name = "name" + i, Category = "Category" + i, SellPrice = i }; ProductList.Add(product); ProductDictionary.Add(Guid.NewGuid().ToString(), product); ProductBlockList.Add(product); ProducutConcurrentDictionary.TryAdd(Guid.NewGuid().ToString(), product); }); }