public void cargaComboMatriculas() { panel.IsEnabled = false; gestionAlquileresViewModel.PanelLoading = true; Thread t = new Thread(new ThreadStart(() => { ServerServiceVehiculo serverServiceVehiculo = new ServerServiceVehiculo(); ServerResponseVehiculo serverResponseVehiculo = serverServiceVehiculo.GetAllFilter("null", "null", "null", "true"); if (200 == serverResponseVehiculo.error.code) { Dispatcher.Invoke(new Action(() => { listaVehiculos = serverResponseVehiculo.listaVehiculo; })); foreach (var item in serverResponseVehiculo.listaVehiculo) { Dispatcher.Invoke(new Action(() => { observableCollectionMatriculas.Add(item.matricula); })); } Dispatcher.Invoke(new Action(() => { cmbMatricula.SelectedIndex = 0; })); } Dispatcher.Invoke(new Action(() => { panel.IsEnabled = true; })); Dispatcher.Invoke(new Action(() => { gestionAlquileresViewModel.PanelLoading = false; })); })); t.Start(); }
private void btnBuscar_Click(object sender, RoutedEventArgs e) { panel.IsEnabled = false; vehiculosViewModel.PanelLoading = true; string matricula = "null"; Object selectedPlazas = cmbPlazas.SelectedItem; string plazas = "null"; Object selectedTam = cmbTamanio.SelectedItem; string tam = "null"; Object selectedDisp = cmbDisponibilidad.SelectedItem; string disp = "null"; if (!txtMatricula.Text.Equals("")) { matricula = txtMatricula.Text.ToString(); } if (null != selectedPlazas && 0 < cmbPlazas.SelectedIndex) { plazas = selectedPlazas.ToString(); } if (null != selectedTam && 0 < cmbTamanio.SelectedIndex) { tam = selectedTam.ToString(); } if (null != selectedDisp && 0 < cmbDisponibilidad.SelectedIndex) { if (Constantes.Disponibilidad.Si.Equals(selectedDisp)) { disp = "true"; } else { disp = "false"; } } Thread t = new Thread(new ThreadStart(() => { ServerServiceVehiculo serverServiceVehiculo = new ServerServiceVehiculo(); ServerResponseVehiculo serverResponseVehiculo = serverServiceVehiculo.GetAllFilter(matricula, plazas, tam, disp); if (200 == serverResponseVehiculo.error.code) { //Limpiar la lista para recuperar la informacion de la busqueda Dispatcher.Invoke(new Action(() => { observableCollectionVehiculo.Clear(); })); foreach (var item in serverResponseVehiculo.listaVehiculo) { if (item.disponibilidad) { item.urlImage = "/Images/ico_verde.png"; } else { item.urlImage = "/Images/ico_rojo.png"; } Dispatcher.Invoke(new Action(() => { observableCollectionVehiculo.Add(item); })); } } else { Dispatcher.Invoke(new Action(() => { msgError(serverResponseVehiculo.error.message); })); } Dispatcher.Invoke(new Action(() => { panel.IsEnabled = true; })); Dispatcher.Invoke(new Action(() => { vehiculosViewModel.PanelLoading = false; })); })); t.Start(); }