private async void InsertItemButton_Click(object sender, EventArgs e) { if (CheckNulls(InsertItem)) { DisableControls(InsertItem); Item item = new Item() { Name = ItemName.Text, Description = ItemDescription.Text, Main = mainCategories[ItemMainCategory.SelectedIndex], Sub = subCategories[ItemSubCategory.SelectedIndex] }; await Task.Run(() => { cms.InsertItems(item); cms.TerminateConnection(); }); EnableControls(InsertItem); Close(); } }