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,开发者_JAVA百科 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.
精彩评论