private void btnAceptarClientes_Click(object sender, RoutedEventArgs e) { if (modo == Constantes.NUEVO) { var dialog = new CustomMessageBox { Caption = "Nuevo", InstructionHeading = "¿Está seguro que quiere guardar el cliente?", InstructionText = "Esta acción guardará la información del cliente", }; dialog.SetButtonsPredefined(EnumPredefinedButtons.OkCancel); var result = dialog.ShowDialog(); if (result.HasValue && result.Value && dialog.CustomCustomDialogResult == EnumDialogResults.Button1) { if (cambiosCliente()) { txtError.Text = ""; panel.IsEnabled = false; gestionClientesViewModel.PanelLoading = true; Thread t = new Thread(new ThreadStart(() => { ServerServiceCliente serverServiceCliente = new ServerServiceCliente(); ServerResponseCliente serverResponseCliente = serverServiceCliente.Save(clienteModif, "null"); if (200 == serverResponseCliente.error.code) { Dispatcher.Invoke(new Action(() => { mostrarAutoCloseMensaje("Nuevo", "Se ha guardado el cliente correctamente."); })); Dispatcher.Invoke(new Action(() => { gestionClientesViewModel.cliente = clienteModif; })); Dispatcher.Invoke(new Action(() => { volver(); })); } else { Dispatcher.Invoke(new Action(() => { msgError(serverResponseCliente.error.message); })); } Dispatcher.Invoke(new Action(() => { panel.IsEnabled = true; })); Dispatcher.Invoke(new Action(() => { gestionClientesViewModel.PanelLoading = false; })); })); t.Start(); } } } else { var dialog = new CustomMessageBox { Caption = "Modificar", InstructionHeading = "¿Está seguro que quiere modificar el cliente?", InstructionText = "Esta acción modificará la información del cliente", }; dialog.SetButtonsPredefined(EnumPredefinedButtons.OkCancel); var result = dialog.ShowDialog(); if (result.HasValue && result.Value && dialog.CustomCustomDialogResult == EnumDialogResults.Button1) { if (cambiosCliente()) { txtError.Text = ""; panel.IsEnabled = false; gestionClientesViewModel.PanelLoading = true; Thread t = new Thread(new ThreadStart(() => { ServerServiceCliente serverServiceCliente = new ServerServiceCliente(); ServerResponseCliente serverResponseCliente = serverServiceCliente.Save(clienteModif, clienteModif.id); if (200 == serverResponseCliente.error.code) { Dispatcher.Invoke(new Action(() => { mostrarAutoCloseMensaje("Modificar", "Se ha modificado el cliente correctamente."); })); Dispatcher.Invoke(new Action(() => { gestionClientesViewModel.cliente = clienteModif; })); Dispatcher.Invoke(new Action(() => { volver(); })); } else { Dispatcher.Invoke(new Action(() => { msgError(serverResponseCliente.error.message); })); } Dispatcher.Invoke(new Action(() => { panel.IsEnabled = true; })); Dispatcher.Invoke(new Action(() => { gestionClientesViewModel.PanelLoading = false; })); })); t.Start(); } } } }