private async void InsertItem_VisibleChanged(object sender, EventArgs e) { if (InsertItem.Visible) { ItemMainCategory.Enabled = false; ItemSubCategory.Enabled = false; await Task.Run(() => { cms.InitializeConnection(); mainCategories = cms.GetAllMainCategories(); subCategories = cms.GetAllSubCategories(); }); ItemMainCategory.Enabled = true; ItemSubCategory.Enabled = true; foreach (var mainCategory in mainCategories) { ItemMainCategory.Items.Add(mainCategory); } foreach (var subCategory in subCategories) { ItemSubCategory.Items.Add(subCategory); } } }