简体   繁体   中英

Asynchronous WCF service blocks ASP application

I have an ASP (MVC2) application that is calling a WCF Service. The service is going to take a long time, so I don't want the client ASP application to wait for it to finish. It records its status in the database, and that is available to the ASP client.
I am calling the service asynchronously, but my ASP application still hangs when it trys to transition to the next page. I suspect it is because of the thread hanging waiting for the service to reply. What is the best way to implement this interface so that the ASP application can continue and not be blocked?

If you don't want to know result of web service call you don't need asynchronous call. You need one way (also known as fire and forget) call. Add IsOneWay=true to your OperationContract like:

[ServiceContract]
public interface MyServiceContract
{
  [OperationContract(IsOneWay=true)]
  void MyOperation(Data data);
}

One way operation must return void . Client will only wait to estabilish connection and send data. It will not wait for end of processing.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM