private async void btnClose_Click(object sender, EventArgs e) { Close(); object existingObject = typeof(ConnectionProfile).GetProperties().FirstOrDefault(x => x.Name == structureObject.ObjectType.ToString()).GetValue(profile); string oldName = ((StructureObject)existingObject).InternalName; if (txtName.Text != oldName) { bool result = await StructureManager.UpdateName((StructureObject)existingObject, txtName.Text, profile); if (!result) { new MessageForm("Alert", "Data could not be updated.").ShowDialog(); } } }