AzureIoTHubConnectedService.AccountPicker.Picker_PropertyChanged C# (CSharp) Method

Picker_PropertyChanged() private method

private Picker_PropertyChanged ( object sender, PropertyChangedEventArgs e ) : void
sender object
e System.ComponentModel.PropertyChangedEventArgs
return void
        private async void Picker_PropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            // The property changed event can get raised on the non-UI thread.  This causes issues
            // from logic expecting the UI thread.
            await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

            if (e.PropertyName == nameof(IWpfAccountPicker.SelectedAccount))
            {
                try
                {
                    this.isRespondingToSelectedAccountPropertyChanged = true;
                    await this.viewModel.SetAccountAsync((Account)this.picker.SelectedAccount);
                }
                finally
                {
                    this.isRespondingToSelectedAccountPropertyChanged = false;
                }
            }
            else if (e.PropertyName == nameof(IWpfAccountPicker.SelectedAccountAuthenticationState))
            {
                this.viewModel.IsAuthenticated =
                    this.picker.SelectedAccountAuthenticationState == AuthenticationState.Authenticated;
            }
        }