传统ASMX web服务 - 如何使用自动地生成异步方法 [英] Legacy ASMX webservice - How to use automagically generated async method

查看:322
本文介绍了传统ASMX web服务 - 如何使用自动地生成异步方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个Web服务的ASMX我添加Web引用到公开服务中有多个方法名,例如,

In a asmx webservice i use with c# class library project after adding the web reference to the project which exposes the WebMethods inside the service there are multiple method names for example,

在我的服务我有一个名为的WebMethod GetCategories 但智能感知也说明 GetCategoriesAsync

In my service i have a webmethod named GetCategories but the intellisense also shows GetCategoriesAsync

这是一个异步调用相同的webmethod?如果是的话我怎么可以调用此异步方法的例子?

Is this a asynchronous call to the same webmethod? If so how can i invoke this asynchronous method any examples ?

推荐答案

您可以调用的方法一样调用常规的方法,你也应该在你可以回应签署该方法完成事件的函数,使继续proccess。

You can call the method the same as you call the regular method, you should also sign up a function to the method completion event so that upon a response you could continue the proccess.

这是我发现的一个例子

protected void Button1_Click
(object sender, EventArgs e)
{
     BookSupplier1.WebService1 supplier1 = new BookSupplier1.WebService1();

     supplier1.GetCostCompleted += new BookSupplier1.GetCostCompletedEventHandler(supplier1_GetCostCompleted);

     supplier1.GetCostAsync(TextBox1.Text, BulletedList1);

}


void supplier1_GetCostCompleted(object sender, BookSupplier1.GetCostCompletedEventArgs e)
{
     if (e.Error != null)
     {
         throw e.Error;
     }
     BulletedList list = (BulletedList)e.UserState;
     list.Items.Add("Quote from BookSupplier1 : " + e.Result.ToString("C"));
}

实例链接

这篇关于传统ASMX web服务 - 如何使用自动地生成异步方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆