Is ASMX WebService or WCF or aspx pages are async by default?

有些话、适合烂在心里 提交于 2019-12-12 01:54:08

问题


I involved my self within a bet, our feud is about - Async WebServices and the other stuff i mentioned above.

I am thinking logically web service by default is sync, the other said that it is not correct. Who is right or wrong can any one explain it to me?

Thanks in advance.


回答1:


All of them are by default synchronous but you can write all of them asynchronously and you can call all of them asynchronously. You should always differ between synchronous/asynchronous call and between synchronous/asynchronous execution.

Calls

  • Synchronous - client calls the service/page and hangs on until the service/page returns the response.
  • Asynchronous - client calls the service/page and can continue in work. Client is usually notified by some event (or it can poll the result) that response has arrived. In ASPX this is typical callback or AJAX call.

Execution:

  • Synchronous - service/page receives the call and process it. Every external processing (file access, calling other services, calling database) is done synchronously and the service/page block the executing thread for the whole duration of the request processing.
  • Asynchronous - service/page receives the call, prepares external processing and executes it asynchronously. Processing thread is returned back to thread pool and can server other requests in the meanwhile. Once external processing ends service/page execution is again scheduled to receive a thread from thread pool and it finishes execution and returns response. This is usually only need on high traffic pages/services with intensive external communication.

These two types of asynchronous processing are completely independent. You can have asynchronous calls to synchronous services and any other combination.



来源:https://stackoverflow.com/questions/6213423/is-asmx-webservice-or-wcf-or-aspx-pages-are-async-by-default

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!