我正在实现一个忙碌指示器,以使用ProgressDialog处理我的登录过程,是的,我知道它已经过时了,但是它满足了要求。我遇到的问题是对Web服务的调用失败(是的,我知道它已贬值),没有错误,没有任何问题。我的代码是:
private async void MyLogon()
{
nDialog = new ProgressDialog(this);
nDialog.SetMessage("Validating ...");
nDialog.SetTitle("Log On");
nDialog.Indeterminate = false;
nDialog.SetCancelable(true);
nDialog.Show();
var thread = new System.Threading.Thread(new ThreadStart(delegate
{
// Set the protocol
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
// Instanciate the service
DataInterfaceWeb.DataInterface myService = new OMLDataInterfaceWeb.OMLDataInterface();
// Fails here, cannot trap any error
result = myService.Logon(MyUser.Username, MyUser.Password);
}));
thread.Start();
while (thread.ThreadState == ThreadState.Running)
{
await Task.Delay(100);
}
}
解决这个问题的地方不多,有一篇文章建议将await
与wait
相对使用,但我已经使用过。有人有什么想法吗?