【发布时间】:2014-05-30 11:48:24
【问题描述】:
我正在尝试调用/推送一个半大的 tiff 和一个 Gal 文件到 java web 服务。 平台为 Visual Studio 2013,C# windows 窗体应用程序。
我指向 WSDL 文件,“平台”正在为我生成一个服务引用类。 这对我来说都是非常抽象的,这是一件好事,因为我是这个领域的新手。 我勾选了“生成基于任务的代码”,我得到了一个 addSample 和 addSampleAsync 方法。
我填充类字段并将代码向上推送。
addSample 代码运行良好,但会阻塞 UI。
异步代码 addSampleAsync 也可以工作,但速度较慢且不是完全异步的。 addSampleAsync 将 UI 锁定大约一半的处理时间,并且在同一时间段内对 fncTestUpload 的函数调用不会返回。
//Dimensioned at class level
//private static addSamplePortClient Service = new addSamplePortClient();
//private static addSampleResponse Myresult = new addSampleResponse();
//ThisRequest is the WSDL modeled class object.
//This code works, but is slow, 30 seconds on wifi
ResponseType Myresult = Service.addSample(ThisRequest.Request);
MessageBox.Show(Myresult.Message + Myresult.Code);
//This code locks up the UI for about 15 - 20 seconds then takes another 15 to display the messagebox
fncTestUpload(ThisRequest);
async void fncTestUpload(addSampleRequest SentRequest)
{
Myresult = await Service.addSampleAsync(SentRequest.Request);
MessageBox.Show(Myresult.Response.Message + " - " + Myresult.Response.Code);
}
我将响应对象设为类级变量,希望在调用 fncTestUpload 的函数中对其进行处理,它认为在调用 Async 函数时会立即返回。它直到 15 秒后才返回。??
我已经用谷歌搜索了几个小时,但没有找到任何关于为什么 addSampleAsync 没有像宣传的那样工作的答案。
Microsoft 的教程也可以用 Dilbert 的 Elbonian 语言编写。我无法关注它们,也觉得它们没有帮助,所以请不要引导我。
【问题讨论】:
-
与论坛网站不同,我们不使用“谢谢”、“任何帮助表示赞赏”或Stack Overflow 上的签名。请参阅“Should 'Hi', 'thanks,' taglines, and salutations be removed from posts?.
标签: c# web-services soap async-await mtom