Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>ASP.NET has built-in async handlers that let you kick off a request, it runs on a non-handler thread, and may complete on a 3rd thread (differernt from the original request handler thread) all built-in. I've used it tons of times.</p> <p><a href="http://msdn.microsoft.com/en-us/magazine/cc163725.aspx" rel="nofollow noreferrer">http://msdn.microsoft.com/en-us/magazine/cc163725.aspx</a></p> <p>Write yourself a little helper method to hook it all up.</p> <pre><code>/// &lt;summary&gt; /// On load event override /// &lt;/summary&gt; /// &lt;param name="e"&gt;arguments to the event&lt;/param&gt; protected override void OnLoad(EventArgs e) { base.OnLoad(e); string query = this.Page.Request.QueryString["query"]; if (!string.IsNullOrEmpty(query)) { var pat = new PageAsyncTask(this.BeginAsync, this.EndAsync, this.TimeOut, query); this.Page.RegisterAsyncTask(pat); } string me = string.Format(Format, System.Threading.Thread.CurrentThread.ManagedThreadId, "Onload"); Trace.Write(me); } protected override void Render(HtmlTextWriter writer) { string me = string.Format(Format, System.Threading.Thread.CurrentThread.ManagedThreadId, "Render"); Trace.Write(me); this.Icompleted.Text = DateTime.Now.ToString(); base.Render(writer); } /// &lt;summary&gt; /// start the async task /// &lt;/summary&gt; /// &lt;param name="sender"&gt;original caller&lt;/param&gt; /// &lt;param name="e"&gt;unused arguments&lt;/param&gt; /// &lt;param name="cb"&gt;call back routine&lt;/param&gt; /// &lt;param name="state"&gt;saved stated&lt;/param&gt; /// &lt;returns&gt;IAsyncResult to signal ender&lt;/returns&gt; private IAsyncResult BeginAsync(object sender, EventArgs e, AsyncCallback cb, object state) { this.bsc = new YourWebServiceReferenceGoesHere(); return this.bsc.BeginGetResponseXml("1", (string)state, "10", "1", cb, state); } /// &lt;summary&gt; /// when the task completes /// &lt;/summary&gt; /// &lt;param name="ar"&gt;the async result&lt;/param&gt; private void EndAsync(IAsyncResult ar) { XmlResponse response = this.bsc.EndGetResponseXml(ar); this.bsc.Close(); this.bsc = null; this.PostProcess(response); } private void TimeOut(IAsyncResult ar) { // currently we do nothing here. } /// &lt;summary&gt; /// /// &lt;/summary&gt; private void PostProcess(XmlResponse response ) { string me = string.Format(Format, System.Threading.Thread.CurrentThread.ManagedThreadId, "bingsearch"); Trace.Write(me); var xds = new XmlDataSource { EnableCaching = false, CacheDuration = 0, Data = response.Xml, Transform = this.RemoveNamespaces() }; this.some.DataSource = xds; this.some.DataBind(); } </code></pre>
 

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