ASP.NET Web Service call in another Thread

We are making a web service call on some data updates to sync another database. This web service call takes up some response time. Would adding it in a thread help at all? Any downfalls of doing this? If the web service calls fails, it fails and that is it. It is like a fire and forget call.


You could use an Asynchronous Web Service call using asyncronous callbacks to prevent blocking of your main thread.

By making an asynchronous call to a Web service, you can continue to use the calling thread while you wait for the Web service to respond. This means users can continue to interact with your application without it locking up while the Web service access proceeds.

From MSDN: Making Asynchronous Web Service Calls


如果花费足够长的时间来挂起用户界面,那么建议在另一个线程上调用它。


In addition to Tudor's answer I would suggest that you start off by using the new Task class from .NET 4.0.from task parallel library. Example would be:

Task backgroundProcess = new Task(() =>
{
     service.CallMethod();
});
链接地址: http://www.djcxy.com/p/74498.html

上一篇: 从ASP.NET Web应用程序到ASP.NET Web服务到SQL Server的身份验证

下一篇: ASP.NET Web服务在另一个线程中调用