c# - Web服务调用在线程中失败
问题描述
我正在使用 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
vis wait
,但我已经使用了。有人有想法么?
解决方案
推荐阅读
- docker - 向 Juypterhub DockerSpawner 添加额外的主机
- c# - 如何在 C# 中舍入浮点变量
- iframe - 动态更新网站上的 youtube 播放列表
- javascript - 反应路由器4:在onClick链接组件更新状态
- vhdl - VHDL 目标大小
- outlook - 如果我单独购买了桌面应用程序,是否可以在 Outlook 桌面中访问 Office 365 商业基础版电子邮件?
- django - 在views.py中返回渲染请求后自动聚焦在电子邮件字段上
- java - 使用 Woodstox 解析 XML 时保持实体不变
- c - 自定义基本数据类型的输入函数中的 Postgresql 损坏数据
- vue.js - Vue 动态组件排序?