Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>If you make an asynchronous Web service call, the UI <em>might</em> be tied up for a brief period during DNS resolution. <code>BeginGetResponse</code> method resolves DNS <em>before</em> it makes the asynchronous method call to get the response. So if DNS resolution takes any time (it's usually quite fast, but sometimes it can take seconds), the UI will be unresponsive for that period.</p> <p>See <a href="http://blog.mischel.com/2008/06/10/is-this-really-asynchronous/" rel="nofollow">Is This Really Asynchronous?</a> for more details.</p> <p>Beyond that, as long as you process the response in a callback (which is executed on a separate thread), there will be no difference in UI responsiveness. The difference here is that with the asynch requests, the separate thread is active only during processing the result. With a thread doing a synchronous request, the thread is active for the entire duration of request and processing. For most web service calls, processing takes a lot less time than making the request and waiting for the result.</p> <p>If you make <em>lots</em> of requests, then you run the risk of resource exhaustion with one thread per call. But on modern hardware you'd have to be making dozens of requests per second for that to become an issue.</p> <p>All that said, you probably should be using asynchronous web requests. If you're hitting the same domain (or a small number of domains) with those requests, the DNS resolution will be satisfied from the local cache, meaning that it won't take any time at all. And you reduce (almost completely eliminate) the risk of resource exhaustion due to too many concurrent threads.</p> <p>It's interesting to note that documentation for <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetresponse.aspx" rel="nofollow">HttpWebRequest.BeginGetResponse</a> says:</p> <blockquote> <p>The BeginGetResponse method requires some synchronous setup tasks to complete (DNS resolution, proxy detection, and TCP socket connection, for example) before this method becomes asynchronous. As a result, <strong>this method should never be called on a user interface (UI) thread</strong> because it might take considerable time (up to several minutes depending on network settings) to complete the initial synchronous setup tasks before an exception for an error is thrown or the method succeeds. </p> </blockquote> <p>Whereas that's probably good general advice, my comment above still applies: if all your calls are going to the same server or same group of servers (which is usually the case for an in-house app), then that warning is irrelevant. The DNS will be cached, proxy will be set up, etc. If proxy setup takes a lot of time on a per-connection basis, you need to get with your IT department for a resolution. In my experience, asynchronous web requests are the way to go.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload