public VehiculosView() { InitializeComponent(); vehiculosViewModel = (VehiculosViewModel)this.DataContext; panel.IsEnabled = false; vehiculosViewModel.PanelLoading = true; Thread t = new Thread(new ThreadStart(() => { ServerServiceVehiculo serverServiceVehiculo = new ServerServiceVehiculo(); ServerResponseVehiculo serverResponseVehiculo = serverServiceVehiculo.GetAll(); if (200 == serverResponseVehiculo.error.code) { 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; })); Dispatcher.Invoke(new Action(() => { lstVehic.ItemsSource = observableCollectionVehiculo; })); })); t.Start(); }
public void cargaComboMatriculas() { Thread t = new Thread(new ThreadStart(() => { ServerServiceVehiculo serverServiceVehiculo = new ServerServiceVehiculo(); ServerResponseVehiculo serverResponseVehiculo = serverServiceVehiculo.GetAll(); if (200 == serverResponseVehiculo.error.code) { _listaVehiculos = serverResponseVehiculo.listaVehiculo; foreach (var item in serverResponseVehiculo.listaVehiculo) { observableCollectionMatriculas.Add(item.matricula); } } })); t.Start(); }