private async void InserPersonButton_Click(object sender, EventArgs e) { if (CheckNulls(InsertPerson)) { DisableControls(InsertPerson); Person p = new Person() { Name = PersonName.Text, Mail = PersonMail.Text, Location = PersonLocationList.Items.Cast <string>().ToArray(), SSN = long.Parse(PersonSSN.Text), }; await Task.Run(() => { cms.InitializeConnection(); switch (PersonType.SelectedItem as string) { case "Volunteer": cms.InsertVolunteers((Volunteer)p); break; case "Beneficiary": cms.InsertBeneficiary((Beneficiary)p); break; case "Recepient": cms.InsertReceipeients((Recepient)p); break; case "Employee": cms.InsertEmployee((Employee)p); break; } }); EnableControls(InsertPerson); Close(); } }