【发布时间】:2012-12-10 11:25:00
【问题描述】:
我正在尝试使我的 ASP.Net 网站更具可扩展性,但不确定接收 Web 请求的 ASP.Net 线程是否在对 WCF 方法的异步调用完成之前返回到线程池 或者此线程将等待异步调用完成。
对 WCF 方法的异步调用大约需要 20 到 40 秒才能完成。
编辑 1: 我的代码如下所示,用于我调用异步 WCF 方法的页面代码隐藏。 WCF 方法在 WCF 端是异步的,它也是从这个页面代码隐藏中以异步方式调用的。
protected void Page_Load(object sender, EventArgs e)
{
using (ABCService.ServiceClient sc = new ABCService.ServiceClient())
{
// List<ABCService.Product> products = sc.GetDocSummary("Vend1", null, false);//this is synchronous call from client
sc.BeginGetProducts("Vend1",GetProductsCallback, sc);//this is asynchronous call from WCF
}
}
protected void GetProductsCallback(IAsyncResult asyncResult)
{
List<ABCService.Product> products = ((ABCService.ServiceClient)asyncResult.AsyncState).EndGetProducts(asyncResult); //this will call the WCF EndGetProducts method
}
【问题讨论】:
-
您使用的是异步 ASP.NET 页面吗?你能从你的页面显示一些代码吗?
-
Ladislav - 我在原帖的编辑 1 下发布了我的代码。
标签: asp.net wcf asynchronous