private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedInstance)) { ProfileList = null; if (SelectedInstance != null) { new Thread(new ThreadStart( () => { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(+1))); try { // Get and load profile list. var profile_list = SelectedInstance.GetProfileList(InstanceSource.GetAuthenticatingInstance(SelectedInstance), Window.Abort.Token); // Send the loaded profile list back to the UI thread. // We're not navigating to another page and OnActivate() will not be called to auto-reset error message. Therefore, reset it manually. Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)( () => { Wizard.Error = null; ProfileList = profile_list; })); } catch (OperationCanceledException) { } catch (Exception ex) { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.Error = ex)); } finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(-1))); } })).Start(); } } }
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(SelectedInstance)) { ProfileList = null; if (SelectedInstance != null) { new Thread(new ThreadStart( () => { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(+1))); try { // Get and load profile list. var profile_list = SelectedInstance.GetProfileList(InstanceSource.GetAuthenticatingInstance(SelectedInstance), Window.Abort.Token); // Send the loaded profile list back to the UI thread. Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => ProfileList = profile_list)); } catch (OperationCanceledException) { } catch (Exception ex) { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.Error = ex)); } finally { Wizard.Dispatcher.Invoke(DispatcherPriority.Normal, (Action)(() => Wizard.ChangeTaskCount(-1))); } })).Start(); } } }