在进行 CredentialPickerResults 调用后,我的代码被跳过。登录界面不显示,代码跳转到下一个函数,没有完成当前函数中的代码。
它完全跳过 Global.strUsername = credResults.CredentialUserName 和密码,直接进入 GetData() 函数。
public MainPage()
{
this.InitializeComponent();
GetCredentials();
GetData();
}
private async void GetCredentials()
{
CredentialPickerOptions credOptions = new CredentialPickerOptions()
{
AuthenticationProtocol = AuthenticationProtocol.Basic,
CredentialSaveOption = CredentialSaveOption.Selected,
CallerSavesCredential = true,
Caption = "Login",
Message = "Please enter your credentials",
TargetName = ".",
};
CredentialPickerResults credResults = await CredentialPicker.PickAsync(credOptions);
Global.strUsername = credResults.CredentialUserName;
Global.strPassword = credResults.CredentialPassword;
}
private async void GetData()
{
//get data
}