public async Task Initialize(int AtId = -1) { try { IsWorking = true; //if IsMesRelated then first 'get' scanned action type just to make sure she'll be added to the list if missing ActionType nAt = new ActionType(); if (IsMesRelated) { nAt = await new ActionTypesKeeper().GetActionTypeByName(MesString.ActionTypeName); } //load action types to combobox int index = -1; int i = 0; _selectedIndex = -1; ActionTypes = new ObservableCollection <ActionType>(); ActionTypesKeeper keeper = new ActionTypesKeeper(); await keeper.Reload(); foreach (ActionType at in keeper.Items) { ActionTypes.Add(at); if (at.ActionTypeId == AtId) { index = i; } else if (IsMesRelated) { if (at.ActionTypeId == nAt.ActionTypeId) { index = i; } } i++; } if ((AtId >= 0 && index >= 0) || (IsMesRelated && index >= 0)) { SelectedIndex = index; } Task.Run(() => InitializeActions()); //get actions associated with this process Task.Run(() => InitializeParts()); //get parts associated with this process Task.Run(() => InitializeProcessAttachments()); //get files associated with this process Task.Run(() => InitializeCurrentPlace()); //get current place data Task.Run(() => AbandonReasons.Reload()); //get abandon reasons //load places to combobox if (_IsMesRelated) { index = -1; i = 0; _selectedPlaceIndex = -1; Places = new ObservableCollection <Place>(); PlacesKeeper pKeeper = new PlacesKeeper(); List <Place> _p = new List <Place>(); if (MesString.SetName != null) { _p = await pKeeper.GetPlacesBySetName(MesString.SetName); } else { await pKeeper.Reload(); _p = pKeeper.Items; } if (_p != null) { foreach (Place p in _p) { Places.Add(p); if (p.PlaceId == _thisProcess.PlaceId) { index = i; } i++; } } } if (IsMesRelated && index >= 0) { SelectedPlaceIndex = index; } Task.Run(() => InitializeComponents()); IsWorking = false; IsInitialized = true; } catch (Exception ex) { IsWorking = false; throw; } }